要针对不同环境自动执行 web.config 转换,最好使用什么概念?我有以下一项作为执行此操作的选项之一。但是还有比这个 SDT 更好的选择吗?
我尝试使用 XML-Document-Transform 概念为 Test、Staging 和 PROD 等环境生成配置文件。但是生成的 web.config 并没有反映 Test/Staging/RPOD 的变化。
web.config xml:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="personalDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyDevReleaseDB;Integrated Security=True" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="lists.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
下面是带有 xdt 关键字的 Web.PROD.config,它显示在配置管理器的活动解决方案配置中。
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="personalDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleasePRODDB;Integrated Security=True"
xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
我在这里做错了什么?