【问题标题】:Web.config appSettings configSource attribute transformationWeb.config appSettings configSource 属性转换
【发布时间】:2012-03-24 00:47:04
【问题描述】:

我正在尝试使用 web.config 转换更新我的 web.config 文件中 appSettings 元素的 configSource 属性。

我的 web.config 中有以下内容

    <appSettings configSource="Config\appSettings.local.config">
    </appSettings>

我想要这个

    <appSettings configSource="Config\appSettings.prod.config">
    </appSettings>  

当我构建发布时。这没有发生。我的 Web.Release.config 元素中有以下内容

    <appSettings xdt:Transform="SetAttributes(configSource)" configSource="Config\appSettings.prod.config" />

【问题讨论】:

    标签: asp.net .net web-config


    【解决方案1】:

    只有在您部署 Web 应用程序(或创建部署包)时才会发生转换。当您只是构建解决方案时不会发生这种情况。

    http://msdn.microsoft.com/en-us/library/dd465326.aspx

    “对于 Web 应用程序项目,ASP.NET 提供了一些工具,可以在部署时自动更改(转换)Web.config 文件。”

    【讨论】:

      【解决方案2】:

      如果您愿意,您可以在构建时进行转换,只需在您的项目文件中进行一些操作即可。不久前我写了一篇关于这个的帖子,它以 app.config 为中心,但它适用于 web.config,你可能会错过几个步骤!

      http://www.chrissurfleet.co.uk/post/2011/07/27/Faking-Webconfig-transformations-in-appConfig.aspx

      【讨论】:

        猜你喜欢
        • 2017-03-23
        • 2014-05-03
        • 1970-01-01
        • 1970-01-01
        • 2012-06-17
        • 2018-07-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多