调试代码时未转换Web.config [英] Web.config is not transformed when debugging code

查看:106
本文介绍了调试代码时未转换Web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的Web.config文件,下面有一个Web.Test.configWeb.Development.Config等.

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

当我通过测试"配置上的SlowCheetah预览转换时,它似乎可以正确转换值.

When I preview the transformation via SlowCheetah on the Test config, it appears to transform the values correctly.

当我将构建环境从开发"切换到测试"并尝试调试该应用程序时,该应用程序将在主Web.config文件中的任何值下运行(即,它不进行任何转换).

When I switch my build environment from Development to Testing and try to debug the application, the application runs under whatever values are in the main Web.config file (i.e. it is not transforming anything).

在调试时如何使构建环境选择正确的配置,而不是仅使用基本的Web.config文件?这可能吗?

How do I make the build environment pick the correct config when debugging rather than just always using the base Web.config file? Is this possible?

推荐答案

您可以在构建时转换Web.config.将此目标添加到*.csproj文件:

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>

将原始配置保留在Web.Base.config中.启用转换就足够了,它适用于任何XML配置文件.不再需要SlowCheetah.

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/

这篇关于调试代码时未转换Web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆