I'm working with an ASP.NET MVC application which we've started to move up into azure devops (code and pipelines). We have multiple web.config files, one for each environment (test, release, etc.) Earlier, we've built the system for release locally and imported the zip into IIS. During local release (right-click, release), Visual studio takes the Web.*.config file relevant to the current build configuration (Release in our case) and merges it with the base Web.config into a single Web.config file.
Our goal when using pipelines is to not transform the Web.config files in the build step, but instead in the release step. We want to build 1 package, and use that same package on our test, staging and production server, and instead use the xml transform setting in the release pipeline to deliver a different web.config file to different environments. We feel more confident in our process if the same binary is tested all the way through from test to release.
However, whenever I use the "build solution" step it always does the Web.config file transform, no matter which settings I use.
What I've done so far: I've looked at MS documentation but haven't found anything relevant. I've searched through SO and found some threads, this one for instance: web.config transformation does not work on build server says that you need a TransformXml
emelent in your .csproj-file for XML transformations to work, but we don't have one, so I can't remove it and see if that helps :) Most threads seem to suggest passing different flags to msbuild to stop it from transforming the xml file (listed below) but none seem to work. I've found a workaround that doesn't really work with how our project is set up. I've per this github issue removed the <DependentUpon>
tags for the relevant Web.*.config files. Unfortunately, nothing has helped.
This is the YAML for the build step:
steps:
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '**\Source\[redacted]Solution\*.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:PreBuildEvent="" /p:TransformWebConfigEnabled=false /p:AutoParameterizationWebConfigConnectionStrings=false /p:MarkWebConfigAssistFilesAsExclude=false /p:ProfileTransformWebConfigEnabled=false'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
These are the build flags set in the project since before:
/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true
/p:PackageLocation="$(build.artifactstagingdirectory)\\"
/p:PreBuildEvent=""
These are the flags I've tried to use to try to disable Web.Config transformations in build pipeline, none seem to work (tried different combinations):
/p:TransformWebConfigEnabled=false
/p:AutoParameterizationWebConfigConnectionStrings=false
/p:MarkWebConfigAssistFilesAsExclude=false
/p:ProfileTransformWebConfigEnabled=false
So, which flags do I need to pass to msbuild in Azure Pipelines to make it not transform the Web.*.config file?