Like most people I'm using teamcity as a CI tool and I'm also using web config transformations quite heavily, a lot of times to insert config values.
My build process is generally to build the entire solution and then (using msdeploypublish) deploying the website to a website.
Because I'm running msbuild twice, the config transformations are being run twice and so I'm ending up with duplicate values in the final versions of the config files (mainly web.config but I have others as well).
Is there a way to only run the config transformations the one time, for example by using a parameter in msbuild that will stop it from happening?
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.
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).
If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project.
I've found the slightly undocumented InsertIfMissing
which seems to do the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With