In my yaml pipeline, I have a deployment job for IIS web app, in .Net Framework 4.6.1. The build job creates a zip containing all files including the Web.config and Web.Fonc.config, Web.PreProd.config, etc. The Xml transformation works on the old release pipeline (classic) and I would like to work also in my new yaml version. But it doesn't.
Here is a example of the job template :
parameters:
- name: tagsDeploiement
type: string
- name: cheminArtefact
type: string
default: false
- name: environnementsADeployer
type: object
default:
- EnvName: 'Fonc'
jobs:
- ${{ each environment in parameters.environnementsADeployer }}:
- deployment: WebDeployment_${{ replace(environment.EnvName, '-', '_') }}
pool:
name: Default
environment:
name: ${{ environment.EnvName }}
resourceType: virtualMachine
${{ if ne( parameters.tagsDeploiement, '') }}:
tags: ${{ parameters.tagsDeploiement }}
strategy:
runOnce:
deploy:
steps:
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'Deploy Odata Services'
inputs:
WebSiteName: WebServicesA
VirtualApplication: Services.OData
Package: '${{ parameters.cheminArtefact }}/applications/Services.OData.zip'
RemoveAdditionalFilesFlag: true
XmlTransformation: true
XmlVariableSubstitution: false
On the server, the files are copied correctly, the web app works, but the xml transformations did not. The configurations files are copied at the root of the app folder (clicking on "Explore" on the app under the website shows it).
Here is the message I get from the pipeline job output :
##[warning]Unable to apply transformation for the given package. Verify the following. ##[warning]1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the tag for each config in the csproj file and rebuild. ##[warning]2. Ensure that the config file and transformation files are present in the same folder inside the package.
Everything is in the package, copied correctly as I wrote and the transformation is not applied during build.
Web.config section to be replaced :
<system.webServer>
<security>
<authorization>
</authorization>
</security>
And Web.Fonc.config
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<security xdt:Transform="Replace">
<authorization >
<remove users="*" roles="" verbs="" />
<add accessType="Allow" roles="XX-XXX-ROLE" />
</authorization>
</security>
</system.webServer>
</configuration>
Also note that my main pipeline pass 'Fonc' as environment in the parameters (even if it's the default value).
I have checked the YAML sample and the config file settings.
By default, IISWebAppDeploymentOnMachineGroup task will find the web.release.config
to do the file transform.
I can reproduce the same issue if the web.release.config
file doesn't exist.
To solve this issue, you need to set the variable Release.EnvironmentName
on the stage-level or on the job-level to let the IISWebAppDeploymentOnMachineGroup task to find the correct config file.
For example:
variables:
Release.EnvironmentName: ${{ environment.EnvName }}
Here is an example:
parameters:
- name: tagsDeploiement
type: string
- name: cheminArtefact
type: string
default: false
- name: environnementsADeployer
type: object
default:
- EnvName: 'Fonc'
jobs:
- ${{ each environment in parameters.environnementsADeployer }}:
- deployment: WebDeployment_${{ replace(environment.EnvName, '-', '_') }}
pool:
name: Default
variables:
Release.EnvironmentName: ${{ environment.EnvName }}
environment:
name: ${{ environment.EnvName }}
resourceType: virtualMachine
${{ if ne( parameters.tagsDeploiement, '') }}:
tags: ${{ parameters.tagsDeploiement }}
strategy:
runOnce:
deploy:
steps:
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'Deploy Odata Services'
inputs:
WebSiteName: WebServicesA
VirtualApplication: Services.OData
Package: '${{ parameters.cheminArtefact }}/applications/Services.OData.zip'
RemoveAdditionalFilesFlag: true
XmlTransformation: true
XmlVariableSubstitution: false
Result: