我正在使用web.config转换文件概念。我有三个Web配置。一种是暂存,生产,部署。对于这三个,我有不同的连接信息。
Web.Config:
<connectionStrings>
<add name="MyGallery"
connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DevelopmentStorageDb;Data Source=BALA\SQLEXPRESS" />
</connectionStrings>
Web.Config.Production:
<add
name="MyGallery"
connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SharePoint_Config;Data Source=BALA\SQLEXPRESS"
xdt:Transform="Replace" xdt:Locator="Match(name)"
/>
现在,我构建代码,它可以正常工作。我已经创建了包。当我在生产模式下运行代码时,新的连接字符串未占用。
我该如何解决。我需要额外的努力才能将其移动到某个地方吗
最佳答案
要使用的命名是 Web.Production.Config 而不是 Web.Config.Production...
此外,这里使用的更优化转换是 xdt:Transform="SetAttributes(connectionString)"这样 XDT 引擎将只修改 connectionString 属性并保持添加节点原样......
关于visual-studio - VS2010中的Web.Config转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1122492/