MSBuild web.config transforms not working
Asked Answered
B

1

9

I am setting up my application for CI&D. I created a DEV-Deploy web.config transform which contains the connection strings for the dev testing environment.

Web config transforms

Here are the contents of the Web.DEV-Deploy.config connection string section:

  <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>

It should look like:

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

I'm building using the command line and I have tried the following commands, neither of which work:

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

The deploy task looks like this:

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

The web.config looks like this upon deployment:

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

I have tested to the best of my ability on my local machine and have not been able to duplicate the issue. What do I need to do to get the transform working correctly on the build?

Bisector answered 13/6, 2013 at 21:0 Comment(1)
This question appears to be off-topic because it is about a wrong path, not about programming (too localized)Acaleph
B
3

Our CI&D team put the build/deploy scripts into source control and after looking them over, everything above was correct, the problem was the path for the build command was wrong while the command itself was correct.

Once that was updated the web.config transformed correctly.

Bisector answered 14/6, 2013 at 13:44 Comment(1)
May I ask what you used for /T:Package ? How do I create a "package" build target?Abattoir

© 2022 - 2024 — McMap. All rights reserved.