我的ASP.NET MVC項目有三個發佈配置文件。關於發佈配置文件名稱的ASP.NET web.config轉換
我需要添加轉化爲他們所有。對於這樣做,我拿起「添加配置轉換」的web.config文件,並得到了4個Web CONFIGS:
但我不明白我怎麼可以指定任何人以任何發佈配置。例如,我無法找到正確的配置文件來爲開發發佈配置文件進行轉換。我怎樣才能做到這一點 ? 感謝您的任何建議。
我的ASP.NET MVC項目有三個發佈配置文件。關於發佈配置文件名稱的ASP.NET web.config轉換
我需要添加轉化爲他們所有。對於這樣做,我拿起「添加配置轉換」的web.config文件,並得到了4個Web CONFIGS:
但我不明白我怎麼可以指定任何人以任何發佈配置。例如,我無法找到正確的配置文件來爲開發發佈配置文件進行轉換。我怎樣才能做到這一點 ? 感謝您的任何建議。
我創建了一個新的網絡配置,我命名爲 「Web.development.config」。 這是我的項目文件的代碼轉換:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('Web.$(Configuration).config')">
<!-- Generate transformed app config in the intermediate directory -->
<TransformXml Source="Web.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="Web.$(Configuration).config" />
<!-- Force build process to use the transformed configuration file from now on. -->
<ItemGroup>
<AppConfigWithTargetPath Remove="Web.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
所以用這個解決方案,您可以使用Web.<your publish profile name>.config
感謝您花時間留下這個答案 - 幫助我非常。 – kape123
當發佈你選擇你想發佈您的配置,它會選擇相當於Web配置文件。 –
@PaulKaram謝謝,但我認爲我需要在所有情況下使用「發佈」配置...所以我認爲這不是一個好的解決方案... – neustart47
在您的MVC項目下,展開屬性,並且您會發現所有配置文件在PublishProfiles文件夾下。您可以直接編輯'mysite-environment - Web Deploy.pubxml'文件。我想'' Release LastUsedBuildConfiguration>'是你想要的嗎? –
garethb