Web配置转换不起作用 [英] Web Config Transform not working

查看:124
本文介绍了Web配置转换不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET MVC 3.0应用程序中,我在appSettings中具有以下配置:

In a .NET MVC 3.0 Application I have the following configuration in appSettings:

<appSettings>
<add key="SMTPHost" value="mail.domain.com"/>
    <add key="SMTPUsername" value="user@gmail.com"/>
    <add key="SMTPPort" value="25"/>
    <add key="SMTPPwd" value="mypassword"/>
    <add key="EmailFrom" value="notific@gmail.com"/>
</appSettings>

对于调试,我定义了以下配置转换:

For debugging, I have the following configuration transform defined:

<appSettings>
    <add  key="SMTPPort" value="58" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>

然后我以调试模式运行该应用程序,但是我的SMTP端口仍然从web.config而不是web.Debug.config获取值.

And I run the application in debug mode, but my SMTP port is still taking the value from the web.config, not web.Debug.config.

任何人都可以建议此配置有什么问题吗?

Can anyone suggest what could be wrong in this configuration?

推荐答案

Web.config转换仅作为发布操作的一部分来应用.

The Web.config transforms are only applied as part of a publish operation.

如果希望将此操作作为app.config生成操作的一部分进行,则可以使用SlowCheetah-XML Transforms Visual Studio插件:

If you wish this to be done as part of an app.config build operation, then you can use the SlowCheetah - XML Transforms Visual Studio plugin:

http://visualstudiogallery.msdn.microsoft.com/69023d00- a4f9-4a34-a6cd-7e854ba318b5

这篇关于Web配置转换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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