Web.config is not transformed when debugging code

后端 未结 2 1960
小蘑菇
小蘑菇 2020-12-05 03:16

I have a main Web.config file, and under that there is a Web.Test.config, Web.Development.Config etc.

When I preview the trans

相关标签:
2条回答
  • 2020-12-05 03:28

    You can transform Web.config on build. Add this target to *.csproj file:

    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" />
    <Target Name="BeforeBuild">
        <TransformXml 
            Source="Web.Base.config" 
            Transform="Web.$(Configuration).config" 
            Destination="Web.config" />
    </Target>
    

    Keep the origin configuration in Web.Base.config. It's enough to enable transformation and it works for any XML config file. SlowCheetah is no longer needed at all.

    http://sebnilsson.com/a5410281/asp-net-transform-web-config-with-debug-release-on-build/

    0 讨论(0)
  • 2020-12-05 03:29

    XML transformations will only be applied when you publish web apps and not during build.

    This blog post details a work around using build settings.

    0 讨论(0)
提交回复
热议问题