I have a build pipeline which publishes a build artifact to path $(Build.ArtifactStagingDirectory). I have a release pipeline with 1 stage following the IIS website deployment template. The IIS web App Deploy task is set to use Xml Transformation, and the deployment executes successfully. The website is created in IIS, but the web.config is not transformed correct.
My Stage is called "MyEnvironment", and I have a web.config and a web.MyEnvironment.Config file in the project, which transforms correctly in visual studio transform preview and if I publish from visual studio. If I look at the logs for my release pipeline, I see that the IIS Web App Deploy task executed successfully but there were warnings:
2022-02-09T19:05:07.5762631Z ##[warning]Unable to apply transformation for the given package. Verify the following.
2022-02-09T19:05:07.5773252Z ##[warning]1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the <DependentUpon> tag for each config in the csproj file and rebuild.
2022-02-09T19:05:07.5775568Z ##[warning]2. Ensure that the config file and transformation files are present in the same folder inside the package.
My understanding was that the xml transformation of an IIS Web App Deploy task would use the name of the stage as the environment when searching for the web.config transform to use. I'm sure that the stage name matches the web..config file, yet it is still not transforming correctly. Is there something I'm missing here?
trigger:
- Development
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
# msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)" /p:AutoParameterizationWebConfigConnectionStrings=False'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'