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.
Based on my test, XML variable substitution
and XML transformation
could work at the same time.
Here is the original web.config file:
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
).
In the temp folder, I noticed that the file has been transformed successfully.
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.
Update:
Here are some details:
Files:(web.config and web.qa.config)
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:
Task settings:
Summary: the webpages:Version
is changed by variable substitution. The others are changed by xml transformation.