Azure DevOps XML Transformation During Release Not Working

前端 未结 4 680
北荒
北荒 2020-12-17 01:29

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

4条回答
  •  情深已故
    2020-12-17 02:13

    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.

    Some short info about my setup

    I want to be able to deploy on all environments with just one build and one release pipeline.

    My setup:

    • One build pipeline that builds all of our standard branches (test, release, master).
    • One release pipeline that has different stages depending on branch that started the release.

    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.

    Solution

    I followed some of the guide from Microsoft and set up my web..config 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=False

    The 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.

提交回复
热议问题