Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild web.config transforms not working

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?

like image 721
drneel Avatar asked Jun 13 '13 21:06

drneel


1 Answers

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.

like image 198
drneel Avatar answered Sep 30 '22 19:09

drneel