azure-devopsazure-pipelinesazure-pipelines-release-pipelineazure-deploymentazure-pipelines-release-task

Web.config variable update not working with Azure DevOps pipeline (File Transform)


I'm trying to use the task "File Transform" within my pipeline to modify a few values inside my web.config file during deployment.

I created the tasks as the following:

enter image description here

And in the pipeline, inside the variables, I set up the key & value that I want to replace in the XML file.

Everything seems to go fine, however, when I check the log, I see this

enter image description here

So, the file was simple skipped and the transformation didn't work.

The variable that I'm trying to modify in the web.config file has the following path inside the XML file

  <aspNetCore>
   <environmentVariables>
     <environmentVariable  name="x" value="y" />
    </environmentVariables>
   </aspNetCore>
 </configuration>

I read the documentation multiples times, but it's not clear if I'm doing something wrong.

Please, could you provide some suggestion of what I need to check to make it work?

Thank you


Solution

  • I'm answering my own question.

    Based on the comments that I received, the solution that I found was the following:

    1- Use Replace Token Task (https://github.com/qetza/vsts-replacetokens-task#readme) in the pipeline AFTER the deployment. I also removed that "File Transform", since it wouldn't work for what I needed. 2- In the configuration, I pointed the root folder to the deployed application, no the Zip file, as instructed by this other question (Azure Dev ops replace tokens per environment in release pipeline) 3- In the web.config file, I used the token prefix and suffix, as suggested "#{token}# 4- Added the variables to the variable groups

    After deploying, I checked that it worked fine.