Close

TFS Replace Tokens

When building a web application you can use AppSettings in you web.config file to configure (not hard-code) settings like database connection strings. Looking at the web.config file, I noticed variables were used like value=”#{CONNECTIONSTRING_RELATIECORRELATIE_DB}#”.

The reason variables are used is because we want to change the value of variables per environment (DTAP), but how do we go about this? The trick is to
use task Replace Token in your TFS (or DevOps) release definition.

To configure the variables, go to Release Definition tab Configuration. By default we will see Release Variables selected here. In the top right corner is a drop-down where you can change to Environment variables. The Environment Variables show the settings per environment.

You can also use task Replace Tokens in the Build Definition. See link: Go There
This approach is less desirable, because at the build stage you can’t set variables per environment.