【问题标题】:Web.Config Transform Individual AppSettings to ConfigSourceWeb.Config 将单个 AppSettings 转换为 ConfigSource
【发布时间】:2017-03-23 02:24:03
【问题描述】:

我想将本地 web.config 文件的 appsettings 部分从本地开发工作的一组单独设置转换为 configSource 文件路径属性以发布到客户端服务器。

基本上由此而来:

<appSettings>
    <add key="setting1" value="devVal1"></add> 
    <add key="setting2" value="devVal2"></add>
    <add key="setting3" value="devVal3"></add>
</appSettings>

到这里:

<appSettings configSource="clientSettings.config" />

此部分解决方案添加了 configSource 属性。

<appSettings xdt:Transform="SetAttributes(configSource)" configSource="clientSettings.config"/>

但我也不确定如何删除所有单独的设置(我认为 configSource 无论如何都会覆盖它们,但我宁愿根本没有它们,以避免有不相关的开发设置在我的每个客户的 web.config 文件中)

【问题讨论】:

    标签: asp.net xslt web-config web.config-transform


    【解决方案1】:

    更多的毅力让我找到了答案。将“RemoveAll”转换应用于appSetting 中的add 元素。

    <appSettings xdt:Transform="SetAttributes(configSource)" configSource="clientSettings.config">
        <add xdt:Transform="RemoveAll"/>
    </appSetting>
    

    希望这对将来的某人有用(如果只是作为一个例子,说明为什么你应该在到达“”按钮之前做 30 分钟的额外工作)...

    【讨论】:

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