Search code examples
wcfweb-configazure-devopsms-release-management

VSTS: Different Config Files (WCF endpoint addresses) for different environments using RM


I have different projects that are consuming many WCF services. I am using VSTS to automate deployments. Those services target different URLs (endpoint addresses) based on the environment where they are going to be deployed.

I am trying to use web deploy with VSTS release management as suggested in this link:WebDeploy with VSTS, which proposes to create:

  • Parmeters.xml
  • Then, add new task "Replace Tokens" with the specified variable for each environment.

However, i don't guess this will work for me, because it generate tokens only for app settings keys (which is not my case).

Is there is a work around or any other suggestion that could help me to do the configuration part?


Solution

  • "Replace Tokens" task can works with any config file in your project and what content to be replaced is also controlled by you.

    For example, if you want to replace a URL in "myconfig.config" file. You can set the URL in the config file to "#{targeturl}#", and add a "Replace Tokens" task in your definition with the following settings: (You can change the token prefix and suffix, but remember to update it accordingly in the config file since the task find the strings to replace base on it) enter image description here

    And then create a variable "targeturl" in the definition with the actual URL value: enter image description here

    Now, when you start the build/release, the string "#{targeturl}#" in "myconfig.config" file will be replaced with "www.test.com".