【问题标题】:Web.Config Transformation in VS2010VS2010 中的 Web.Config 转换
【发布时间】:2010-11-10 11:38:37
【问题描述】:

我正在研究 web.config 转换文件概念。我有三个网络配置。一种是暂存、生产、部署。我对这三个有不同的连接信息。

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)"
    />

现在我构建了运行良好的代码。我已经创建了包。当我在生产模式下运行代码时,新的连接字符串没有占用。

我该如何解决这个问题。我需要额外的努力才能将它移到某个地方

【问题讨论】:

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


    【解决方案1】:

    要使用的命名是 Web.Production.Config 而不是 Web.Config.Production...

    这里使用的更优化的转换是 xdt:Transform="SetAttributes(connectionString)" 这样 XDT 引擎只会修改 connectionString 属性并保持添加节点不变...

    【讨论】:

      【解决方案2】:

      您能否检查以确保软件包是在正确的配置中构建的(生产)?你能检查一下哪个 web.config 进入了包吗?

      我还没有真正尝试过。

      【讨论】:

      • 仅在生产配置文件设置中创建包。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-27
      • 1970-01-01
      • 2022-02-19
      • 1970-01-01
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多