2

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?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
user2086174
  • 195
  • 1
  • 3
  • 12

3 Answers3

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
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