我的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