Reputation: 437
I want to develop a pipeline for a .net web app using Azure tfs. I used the IIS Web Deploy template/utility already provided for such deployments. In the release pipeline, I am using XML variable transformation. But one issue I am facing is, that in the project, I have multiple .config files and I have included them in my web.config
file as follows
<configuration>
<connectionStrings configSource="None"/>
<appSettings file="None">
</appSettings>
Based on the release for different environments, I perform variable substitution during the release. For example, a folder app_data contains app_sttings_*.config
files and file variable does get replaced. But I am having an issue with the connection String file, I can not get configSource
to change during release.
Am I doing this wrong or missing a step?
Upvotes: 2
Views: 1551
Reputation: 30313
Since the configSource attribute cannot be replaced by the IIS Web App Deploy task. You can use the extension tool Magic Chunks to replace the configSource value.
You can install Magic Chunks extension in your azure devops organization. And add Config transformation task before IIS Web App Deploy task to replace the configSource value.
First you need to define a variable (eg. configSource) to hold configSource value in the Release Pipeline variables section. Then configure the Transformations Section of Config transformation task as below
{
"configuration/connectionStrings/@configSource": "$(configSource)"
}
There is another Replace Tokens task that can replace the configSource value. You can check it out here.
It said in the IIS Web App Deploy task that Variables defined in the Release Pipeline will be matched against the 'key' or 'name' entries in the appSettings, applicationSettings, and connectionStrings sections of the config files. Maybe that is the reason that configSource cannot be replaced by the IIS Web App Deploy task.
See File transforms and variable substitution reference for more information.
Upvotes: 2