I wanted to ask if somebody have ever made changes to Web API .config file values during the Visual Studio Team Services build (replaced with other values)? Are there any best practices or way how I can achieve it?
Asked
Active
Viewed 1,020 times
2
-
Do you mean as `Web.Debug.config` and `Web.Release.config`? If that's `app.config`, have you looked at http://stackoverflow.com/questions/8082662/how-to-select-different-app-config-for-several-build-configurations? – Dovydas Šopa Jun 30 '16 at 07:20
-
I mean Web.config appSettings key values – user2086174 Jun 30 '16 at 07:25
-
Then use `Web.{Build definition}.config`. – Dovydas Šopa Jun 30 '16 at 07:34
3 Answers
0
You can use SlowCheetah to transform the values in the config file base on the build configuration you specified when queue the build.
You can also use Replace Tokens task to replace the strings in the file by the variables you created in the build definition.

Eddie Chen - MSFT
- 29,708
- 2
- 46
- 60
0
You should look at Web.config
transformations. You can have one main Web.config
file and then define transformations needed based on build definition name in files Web.{Build definition name}.config
.
Example of such transformation:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB" connectionString="ReleaseSQLServer"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
Transforms MyDB
connectionString
attribute from any previous value to ReleaseSQLServer
.

Dovydas Šopa
- 2,282
- 8
- 26
- 34
-
How can i pass (if it's possible) VSO defined variables to these configs? – user2086174 Jun 30 '16 at 07:51
-
-
-
1You cannot have variables in definitions like those. These must be hardcoded values. If you want to be more flexible you will need to use some extension. – Dovydas Šopa Jun 30 '16 at 08:29
0
Apart from using Config Transformations, there are a number of extensions that can make your life easier in this respect:

jessehouwing
- 106,458
- 22
- 256
- 341