加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 如何将配置转换应用于外部配置文件

发布时间:2020-12-15 18:32:17 所属栏目:asp.Net 来源:网络整理
导读:我无法在网路上找到我的问题的例子,想知道是否有人知道解决方案。基本上,如果在我们的web.config我们指向另一个文件,像这样: configuration configSections / appSettings file="AppSettings.config"/configuration 那么我们如何将转换应用于该外部文件
我无法在网路上找到我的问题的例子,想知道是否有人知道解决方案。基本上,如果在我们的web.config我们指向另一个文件,像这样:
<configuration>
  <configSections />
  <appSettings file="AppSettings.config">
</configuration>

那么我们如何将转换应用于该外部文件?

基本上,我想创建一个AppSettings.config,AppSettings.Debug.config,AppSettings.Release.config,并有一个转换运行它…这甚至可能吗?

提前致谢,

塞尔吉奥

解决方法

几个解决方法:

Workaround 1

>使用完整值写入AppSettings.Debug.config,AppSettings.Release.config(不带变换属性)
>在您的web.config中,使用转换,替换相应的文件:

web.debug.config

<appSettings file="AppSettings.debug.config" 
             xdt:Transform="SetAttributes" xdt:Locator="Match(file)"/>

web.release.config

<appSettings file="AppSettings.release.config" 
             xdt:Transform="SetAttributes" xdt:Locator="Match(file)"/>

它不太理想,有点失败的转变的目的,但可能适合基于情况比使用像SlowCheetah。

Workaround 2

使用TransformXml构建任务在构建期间转换您的文件,如here和here所示

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读