Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform a web.config transform before publishing with MSBuild

Tags:

I am trying to do a web deploy publish using MS Build for two web applications for internal use and testing. I have set up different solution configurations for each of the environments that i want to publish to. IE DevA, DevB. I have updated all the web.configs to do the correct transformations. As a note, the transforms work when i do a right click publish through Visual Studio so I have ruled those out as the problem. My current bat file that I am running uses this command to do the work:

"C:\Program Files (x86)\MSBuild\12.0\Bin\msbuild" project.csproj /t:Clean;Rebuild;Publish /p:DeployOnBuild=true;PublishProfile=DevB1_API;AllowUntrustedCertificate=True;username=username;password=password

When i run this command the publish works just fine. However, the web.config is not being transformed. Am i missing a msbuild parameter to force this to happen? Any Help would be appreciated! thanks.

like image 708
kmacdonald Avatar asked Mar 28 '14 20:03

kmacdonald


People also ask

How do I create a Web config transform?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).

What is Xdt transformation?

XDT is a simple and straight forward method of transforming the web. config during publishing/packaging. Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix.

Does dotnet publish create Web config?

Bookmark this question. Show activity on this post. dotnet publish -c Release doesn't create this web. config , so I created itself and put it in the solution (odd, because I've never had to do this before).


1 Answers

Apparently, for the transform to be executed, you have to specify a build configuration using:

/p:Configuration=Release

like image 182
helb Avatar answered Dec 07 '22 21:12

helb