visual-studio - VS2010中的Web.Config转换

标签 visual-studio visual-studio-2010 msdeploy web-config-transform

我正在使用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/

相关文章:

c# - 如何使用 GUI 在 Visual Studio 项目中添加和编译 Windows 窗体,而不是直接从 Visual Studio?

javascript - MVC Javascript 和 AJAX,复选框 onchange()

visual-studio - 如何从 VS2010 即时窗口调用 F# 函数

asp.net-mvc - 使用 msdeploy 部署 MVC 站点,包括来自没有虚拟目录设置的 CI 服务器的 IIS 设置

C# 和 WPF - 'System.Reflection.TargetInvocationException' 发生在PresentationFramework.dll 中

wcf - 在 Visual Studio 中构建 WCF 项目时的输出目录

c# - 使用任务在多线程 C# 中进行异常跟踪

powershell - 从 Powershell 中运行 msdeploy.exe

iis - msdeploy 为手动部署创建包

c++ - dll 中的资源字符串在程序中加载后不完全可见