Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Configuration Variables in VSTS Release Management for ASP.NET 4.5 & 5.0 Projects

I've set up 3 environments (Debug, Stage & Production) and created a custom variable named testVariable for each environment within the RELEASE tab of my Visual Studio Team Service project as shown here:

enter image description here

I also have a release variable named testReleaseVariable shared by all the enviornments as shown here:

enter image description here

I can't find any documentation on how to set up my ASP.NET projects in VS to use these variables when developing locally as well as when deploying a build so that they can be injected by the Release Manager.

I have both ASP.NET 4.5 as well as ASP.NET 5.0 projects. My question is: What is the best practice for setting up my Web.Config (for ASP.NET 4.5 projects) or my Config.json (for ASP.NET 5 projects) to work with both the enviornment as well as the release configuration variables in VSTS Release Management.

like image 638
INNVTV Avatar asked Feb 08 '23 09:02

INNVTV


1 Answers

The configuration variables can be used in any of the Tasks.

You can use the configuration variable by using the $(configVarName) in any of the tasks.

Note that directly you can use these variables only in the tasks not inside the files like Web.Config.

To use them inside files and replace them with appropriate values, you can use the Tokenizer Task.

More info is available at this blog post

like image 63
Harshil Lodhi Avatar answered Feb 10 '23 22:02

Harshil Lodhi