Reputation: 2078
How to add PostBuild commands for the web.config xdt transformation so that when a build is queued successfully it will transform the web.config as per the web.platform.config xdt commands.
If the build branch is e.g. OnlineManagement_Dev then the transformation should happen based on the web.debug.config when I queue this branch . If the build branch is e.g. OnlineManagement_UAT then the transformation should happen based on the web.UAT.config when I queue this branch . If the build branch is e.g. OnlineManagement_PROD then the transformation should happen based on the web.PROD.config when I queue this branch .
I tried looking at the below solution but looks like 'TransformXml' task has a file lock bug. Is there any update to the MSBuild which provides a simpler and better solution than this ?
http://www.diaryofaninja.com/blog/2011/09/14/using-custom-webconfig-transformations-in-msbuild
Upvotes: 0
Views: 826
Reputation: 4083
1) The FileLock "bug" is addressed in the code sample in the section where they explain the bug before including the work around.
2) Do you have an environment variable and/or an MsBuild property that contains the branch type? If so, simply use that to determine source.
e.g.
<TransformXml Source="web.UAT.config"
Transform="TransformFile.config"
Destination="Web.config"
StackTrace="true" />
Update the Source using the name of the environment variable or MSBuild Property that contains this value.
<TransformXml Source="web.$(EnvironmentType).config"
Transform="TransformFile.config"
Destination="Web.config"
StackTrace="true" />
Note that if you are building from a command prompt and already have this in an environment variable, wrap the ENVIRONMENT_VARIABLE_NAME like this $(ENVIRONMENT_VARIABLE_NAME), and MsBuild will identify it.
Upvotes: 2