Search code examples
azurevisual-studio-2015azure-devopsalm

Display Visual Studio Team Services Release Name within web app


I'm deploying a web app to Azure using Visual Studio Team Services to build and then release.

During release I'm replacing tokens within the web.config file with environment variables I have setup within the release definition for each environment, staging, production etc.

I have set the Release Name Format to include the build number and release number using the following:

$(Build.BuildNumber).$(rev:r)

I know Release.ReleaseName is provided as a pre-defined global release variable, but how can I access this Release.ReleaseName variable within my app to display it in a footer?


Solution

  • Usually, you can use Tokenization build / release task to transfer the value of a variable into web.config file.

    But since the variable you want to use is filled with the value of another variable, you need to add an additional powershell step to do this.

    Following are the steps for you reference:

    1. Create a new variable. enter image description here

    2. Change the content that you want to replace in web.config to __Eddie__.

    3. Add a powershell step to set the value of "Eddie" to "Release.ReleaseName". enter image description here

    4. Add a Tokenization step to replace the __Eddie__ in config. enter image description here

    Now, when you start the release, the content in web.config will be replaced by the value of Release.ReleaseName.