0
votes

I have been working on the build and release pipelines for a while now, but ran into this issue lately

I am performing config transform on .net application. The issue i am running into is a bit strange .. Variable substitution doesn’t work if xml transformation is enabled too, but will work ONLY when variable substitution is enabled. I didn't knew this was possible, as per me Variable substitution would work after XML transformation is done. I want to use both the options. Like i want to transform the existing config file and then substitute the remaining values with pipeline variables & variable groups. That way i would have less involvement from other teams to get the transformation for all the values as i have a time crunch. Eventually would have everything transformed but for now i want to follow the above approach. The log does say Xml transformation and Variable substitution completed successful, but variable substitution doesn't happen.

Am i missing something very silly? Has anyone faced this kind of issue.

enter image description here

1
any pointers please? still stuck at this issue.AnsibleUser
From the screenshot , it seems that you are using the IIS web app deploy task. If yes, you could check the _temp folder during the process of deployment. The conversion happens in this folder. You could refer to the answer. If there is any misunderstanding, please correct me.Kevin Lu-MSFT

1 Answers

0
votes

Based on my test, XML variable substitution and XML transformation could work at the same time.

Here is the original web.config file:

enter image description here

Check the log, the transformation occurred in the _temp folder instead of the $(System.DefaultWorkingDirectory) (e.g. I use deployment group to run the task, so the $(System.DefaultWorkingDirectory) path is C:\azagent\A18\_work\r4\a).

enter image description here

In the temp folder, I noticed that the file has been transformed successfully.

enter image description here

If the object you deploy is a folder, then this transformation can only be found in the temp folder. After the deployment, the contents of this folder will be automatically deleted after deployment.

If the object you deploy is a zip file, in addition to the temp folder, a zip will be automatically generated in the $(System.DefaultWorkingDirectory) path, and the web.config file in this zip is also successfully transformed.

enter image description here

enter image description here

Update:

Here are some details:

Files:(web.config and web.qa.config)

enter image description here

Web.config:

  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PCWSUser" value="TheUserName" />
  </appSettings>

Web.qa.config:

  <appSettings>
    <add xdt:Transform="Replace" xdt:Locator="Match(key)" key="webpages:Enabled" value="true" />
    <add key="PCWSUser" value="TheUserNameQA" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
  </appSettings>

Release Pipeline variables:

enter image description here

Task settings:

enter image description here

Summary: the webpages:Version is changed by variable substitution. The others are changed by xml transformation.