I want to configure our pipeline to allow one build to be used for multiple environments without having to create separate builds. According to the docs, it seems like it is
None of the answers I found on the internet worked for me on their own for my build and release pipeline. The web.config I got from the release pipeline was always pointing to the non transformed values.
After a few hours pulling my hair I got it to work though.
I want to be able to deploy on all environments with just one build and one release pipeline.
My setup:
Our test stage releases the test branch on our test server. Stage/Production comes from the same release branch but have their own transform files.
I followed some of the guide from Microsoft and set up my web. to match the release stage names.
I did not need to remove the rows from my .csproj for each transform. Instead all I did was set the property Build Action of each transform to Content as shown by the image bellow.
I then added these commands to the build pipeline's Build Solution -> MSBuild Arguments:
/p:MarkWebConfigAssistFilesAsExclude=false/p:TransformWebConfigEnabled=false/p:AutoParameterizationWebConfigConnectionStrings=FalseThe build now does not try to transform the .config on it's own and also does not exclude the transform files from the artifact, allowing the release pipeline to do the transformation instead. Also, keeping the for the transform files lets us have a "cleaner" look inside our code editors.