bitshift
bitshift

Reputation: 6842

File Transform task for app.config connectionstrings

Im setting up a release pipeline task to transform my app.config using variables to replace several connectionstring values. These properties are not in the node, but rather in a seperate node. Does the File Transform task work only with settings in the node or anywhere in the file? The attribute on the connectionstring properties are name and "connectionString", eg.

<connectionStrings>
   <add name="conn1" connectionString="conn 1 string"/>
</connectionStrings>

What do I put in the value field of task?
Something like this?
(a) connectionString="conn 1 changed string"
or
(b) "conn 1 changed string"

Upvotes: 2

Views: 3152

Answers (1)

Hugh Lin
Hugh Lin

Reputation: 19361

First you need to create a Transform file, for example:

enter image description here

Transform file: enter image description here

For details of how translations are processed, see File transforms and variable substitution reference.

To apply XML transformation to configuration files (*.config) you must specify a newline-separated list of transformation file rules using the syntax:

-transform <path to the transform file> -xml <path to the source file> -result <path to the result file>

For example: enter image description here

enter image description here

For details , please refer to this document.

Update:

We can also use XML variable substitution part of File transform task. Then define the required values in release pipeline variables to transform the varibale.

Note : Variable substitution takes effect only on the applicationSettings, appSettings, connectionStrings, and configSections elements of configuration files.

For details , please refer to this document.

Upvotes: 2

Related Questions