title: How to properly do file transforms on Azure Pipelines
body: <p>I am attempting to do file transforms on my Web.config depending on each environment I publish to. Mostly, everything looks fine until I deploy to my UAT stage on the release pipeline.</p>
  <p>In my build pipeline, here is the YAML file that I am using:</p>
  <pre class="lang-yaml prettyprint-override"><code># ASP.NET
  # Build and test ASP.NET projects.
  # Add steps that publish symbols, save build artifacts, deploy, and more:
  # https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
  
  pool:
    vmImage: 'windows-latest'
  
  variables:
    solution: 'SubmissionService.sln'
    buildPlatform: 'Any CPU'
    buildConfiguration: 'Release'
  
  steps:
  - task: NuGetToolInstaller@1
    displayName: 'Install Newer Version on NuGet'
    inputs:
      checkLatest: true
  
  - task: NuGetCommand@2
    displayName: 'Restore NuGet Packages for Solution'
    inputs:
      command: 'restore'
      restoreSolution: '$(solution)'
      feedsToUse: config
      nugetConfigPath: ./Nuget.config
      
  - task: VSBuild@1
    displayName: 'Create Artifact For Solution'
    inputs:
      solution: '$(solution)'
      msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=&quot;$(Build.ArtifactStagingDirectory)&quot; /p:TransformWebConfigEnabled=false /p:AutoParameterizationWebConfigConnectionStrings=false /p:MarkWebConfigAssistFilesAsExclude=false /p:ProfileTransformWebConfigEnabled=false /p:IsTransformWebConfigDisabled=true'
      platform: '$(buildPlatform)'
      configuration: '$(buildConfiguration)'
  
  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts'
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: 'drop'
      publishLocation: 'Container'
  
  </code></pre>
  <p>Here is the area of my <code>Web.config</code> that I want to transform with the file transformation:</p>
  <pre class="lang-xml prettyprint-override"><code> &lt;system.serviceModel&gt;
      &lt;client&gt;
        &lt;endpoint address=&quot;Address_1&quot; name=&quot;BasicHttpBinding_1&quot;/&gt;
        &lt;endpoint address=&quot;Address_2&quot; name=&quot;BasicHttpBinding_2&quot; /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  <p>Here is my <code>Web.UAT.config</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  
  &lt;!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --&gt;
  
  &lt;configuration xmlns:xdt=&quot;http://schemas.microsoft.com/XML-Document-Transform&quot;&gt;
    &lt;system.web&gt;
      &lt;compilation xdt:Transform=&quot;RemoveAttributes(debug)&quot; /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;client&gt;
        &lt;endpoint xdt:Transform=&quot;Replace&quot; xdt:Locator=&quot;Match(name)&quot; address=&quot;Address_3&quot; name=&quot;BasicHttpBinding_1&quot; /&gt;
        &lt;endpoint xdt:Transform=&quot;Replace&quot; xdt:Locator=&quot;Match(name)&quot; address=&quot;Address_4&quot; name=&quot;BasicHttpBinding_2&quot; /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  
  
  </code></pre>
  <p>The build pipelined works fine. In my release pipeline, I have a &quot;Deploy IIS Website/App&quot; task on the UAT stage and I have both the <code>XML transforms</code> and <code>XML Variable Substitution</code> checkboxes checked.</p>
  <p>After I deploy, the UAT web.config is similar to the web.config on the DEV stage. I created another task, File transform task, to do the file transformation. That task shows succeeded, but the config file still isn't changed.</p>
  <p>This is the part of the log on Azure that says that the transformations were successful:</p>
  <pre><code>2020-12-15T16:23:37.1236261Z ==============================================================================
  2020-12-15T16:23:37.1236588Z Task         : IIS web app deploy
  2020-12-15T16:23:37.1236857Z Description  : Deploy a website or web application using Web Deploy
  2020-12-15T16:23:37.1237081Z Version      : 0.178.0
  2020-12-15T16:23:37.1237278Z Author       : Microsoft Corporation
  2020-12-15T16:23:37.1237595Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
  2020-12-15T16:23:37.1237965Z ==============================================================================
  2020-12-15T16:23:56.5036495Z ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.
  2020-12-15T16:23:56.5141446Z [command]C:\agent\_work\_tasks\IISWebAppDeploymentOnMachineGroup_1b467810-6725-4b6d-accd-886174c09bba\0.178.0\ctt\ctt.exe s:C:\agent\_work\_temp\temp_web_package_2874722683939497\Content\D_C\a\1\s\SubmissionService\obj\Release\Package\PackageTmp\Web.config t:C:\agent\_work\_temp\temp_web_package_2874722683939497\Content\D_C\a\1\s\SubmissionService\obj\Release\Package\PackageTmp\Web.UAT.config d:C:\agent\_work\_temp\temp_web_package_2874722683939497\Content\D_C\a\1\s\SubmissionService\obj\Release\Package\PackageTmp\Web.config pw i verbose
  2020-12-15T16:23:58.6903744Z XML Transformations applied successfully
  </code></pre>
  <p>I also went on the <code>.csproj</code> file the removed the  tags and added the config files as , but still to no end.</p>
  <p>Here is the .csproj:</p>
  <p><a href="https://i.stack.imgur.com/cDpY4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cDpY4.png" alt="enter image description here" /></a></p>
  <p>How can I use file transforms properly to transform the addresses attribute on the  tag?</p>