9

我正在为 CI&D 设置我的应用程序。我创建了一个 DEV-Deploy web.config 转换,其中包含开发测试环境的连接字符串。

Web 配置转换

以下是 Web.DEV-Deploy.config 连接字符串部分的内容:

  <connectionStrings xdt:Transform="RemoveAttributes(configSource)">
    <add name="DbContext"
      providerName="MySql.Data.MySqlClient"
      connectionString="CXN_STRING"
      xdt:Transform="Insert" xdt:Locator="Match(name)"/>
    <add name="elmah"
      connectionString="CXN_STRING"
      xdt:Transform="Insert" xdt:Locator="Match(name)"/>
  </connectionStrings>

它应该看起来像:

  <connectionStrings>
    <add name="DbContext" providerName="MySql.Data.MySqlClient"
      connectionString="CXN_STRING"/>
    <add name="elmah" connectionString="CXN_STRING"/>
  </connectionStrings>

我正在使用命令行进行构建,并且尝试了以下命令,但都不起作用:

msbuild web\web.csproj /T:Package /P:Configuration=DEV-Deploy /P:TransformConfigFiles=true
msbuild web\web.csproj /T:Package /P:Configuration=DEV-Deploy /t:TransformWebConfig

部署任务如下所示:

web.deploy.cmd /Y /M:https://MACHINEIP:8172/msdeploy.axd -allowUntrusted /U:USERNAME /P:PASSWORD /A:Basic

web.config 在部署时看起来像这样:

<connectionStrings configSource="connectionStrings.config"></connectionStrings>

我已尽我所能在本地机器上进行了测试,但无法复制该问题。我需要做什么才能使转换在构建上正常工作?

4

1 回答 1

3

我们的 CI&D 团队将构建/部署脚本放入源代码控制中,经过查看后,上面的一切都是正确的,问题是构建命令的路径错误,而命令本身是正确的。

更新后,web.config 将正确转换。

于 2013-06-14T13:44:16.080 回答