0

This seems like an unusual issue, where the web.config transformation is actually occurring, but the result is not being copied to the web root.

Example line from web.config:

<compilation debug="true" targetFramework="4.8" /> 

Example line from web.release.config:

<compilation xdt:Transform="RemoveAttributes(debug)" /> 

Things I've checked:

  1. Pipieline definitely has all files available, working folder contains:

    web.config web.Debug.config web.Release.config 
  2. According to the pipeline logs, transformation does occur:

    2022-07-27T21:12:39.8206023Z PreTransformWebConfig: 2022-07-27T21:12:39.8206775Z Found The following for Config tranformation: 2022-07-27T21:12:39.8207287Z web.config 2022-07-27T21:12:39.8207966Z Creating directory "D:\a\1\s\Integral.Web.AlbertSite\obj\Release\TransformWebConfig\transformed\". 2022-07-27T21:12:39.8249474Z Copying web.config to obj\Release\TransformWebConfig\original\web.config. 2022-07-27T21:12:39.8259591Z Copying D:\a\1\s\Integral.Web.AlbertSite\Web.Release.config to obj\Release\TransformWebConfig\assist\web.config. 2022-07-27T21:12:39.8293749Z TransformWebConfigCore: 2022-07-27T21:12:39.8294503Z Transforming Source File: D:\a\1\s\Integral.Web.AlbertSite\web.config 2022-07-27T21:12:39.8463519Z Applying Transform File: D:\a\1\s\Integral.Web.AlbertSite\Web.Release.config 2022-07-27T21:12:39.8893847Z Output File: obj\Release\TransformWebConfig\transformed\web.config 2022-07-27T21:12:39.9111483Z Transformation succeeded 2022-07-27T21:12:39.9149601Z PostTransformWebConfig: 2022-07-27T21:12:39.9150514Z Transformed web.config using D:\a\1\s\Integral.Web.AlbertSite\Web.Release.config into obj\Release\TransformWebConfig\transformed\web.config. 
  3. Viewed the file obj\Release\TransformWebConfig\transformed\web.config on the production server, and it is all correctly transformed.

So the transformation occurs, with the resulting correct web.config in obj\Release\TransformWebConfig\transformed\web.config on the server. However, the web.config file in the root folder remains untransformed.

It's like there should have been an extra step of copying the transformed file to the web root, which did not occur. Am I missing a flag or instruction in the YAML which fixes this?

The YAML is below:

trigger: - deploy-production pool: vmImage: 'windows-2019' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: # Install nuget and get solution dependencies. - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' # Build solution. - task: VSBuild@1 inputs: solution: '$(solution)' vsVersion: '16.0' clean: false msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:CreatePackageOnPublish=true /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DeleteExistingFiles=False /p:publishUrl="$(build.artifactStagingDirectory)"' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' # Deploy files to the staging slot. - task: AzureRmWebAppDeployment@4 condition: succeeded() inputs: ConnectionType: 'AzureRM' azureSubscription: 'Pay-As-You-Go (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' appType: 'webApp' WebAppName: 'tulips-webapp-production' deployToSlotOrASE: true ResourceGroupName: 'Tulips-AusEast' SlotName: 'staging' packageForLinux: '$(Build.SourcesDirectory)/Tulips.WebApp' enableCustomDeployment: true DeploymentType: 'webDeploy' TakeAppOfflineFlag: false RenameFilesFlag: false # Swap the staging slot into production. - task: AzureAppServiceManage@0 condition: succeeded() inputs: azureSubscription: 'Pay-As-You-Go (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' Action: 'Swap Slots' WebAppName: 'tulips-webapp-production' ResourceGroupName: 'Tulips-AusEast' SourceSlot: 'staging' 

I'm thinking of simply adding a step to copy obj\Release\TransformWebConfig\transformed\web.config to the root, before the "Deploy files to the staging slot" step. This seems hacky though, so I'm wondering if I've missed something?

1 Answer 1

1

Look at where you're publishing your outputs to versus where you're deploying from. They are different locations.

/p:publishUrl="$(build.artifactStagingDirectory)"

versus

packageForLinux: '$(Build.SourcesDirectory)/Tulips.WebApp'

You're building a publish package, then completely ignoring that publish package and deploying something else.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.