Using Microsoft's documentation plus this answer I am trying to get my Web.Config transform files to be deployed as Azure DevOps artifacts so that I can apply different transforms while publishing builds into different environments.
My goal is to:
- Set
debug=false
for all environments (or remove the attribute entirely, which is seemingly only possible by a transform file) - Change an
<appsettings/>
value for each deployment environment.
As per the above links, I set my Web.Release.Config file to copy to the output directory:
This is verified in the project file:
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
When this change is merged to the Master branch (triggering a build and release) I see in the artifacts ZIP file that only the original web.config file from development is there. No transform files are published to DevOps.
Reading into this further I am aware that transformations have to be prevented in the YAML file so that the <DependentUpon>Web.Config
setting can be maintained for a cleaner solution explorer, so have done this also:
- task: VSBuild@1
inputs:
solution: '$(Build.SourcesDirectory)\My App\App Project 03.csproj'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PrecompileBeforePublish=true;EnableUpdateable=false /p:TransformWebConfigEnabled=False /p:AutoParameterizationWebConfigConnectionStrings=False /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
What am I missing please, or am I going about this all wrong??