我在网络上找不到我的问题的示例,并且想知道是否有人知道解决方案。基本上,如果在我们的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转换文件
关于asp.net - 如何将配置转换应用于外部配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8079197/