8

I am trying to replace an appSetting at release time using VSTS Release. All post on the web refer to the old release management tool or refer to the new one but mention the replace tokens task. This task does not exist so I presume it is built in. I have set up my web.config (MyVar) and set up my environment variables but nothing gets replaced.

enter image description here

And here is my release: enter image description here

I apologise if I am being stupid but I just can't work this out, mostly due to out of date documentation.

Update 2: Ok so after some help from a couple of people I am now on the right track with this. I have added the Colin's ALM tokenisation task: https://marketplace.visualstudio.com/items?itemName=colinsalmcorner.colinsalmcorner-buildtasks

However, it doesn't work.

Here are a couple of screen shots: enter image description here Note that in the screen shot, I know it is disabled. This is just until I can get it fixed.

In the following screen shot, I see the only a few locations to choose where the tokenisation occurs. Does this look correct or should I be able to see the Web.Config in which I want the tokens to be replaced?

enter image description here

As I said, the tokenisation didnt work.

I tried a couple of changes to try to get it to work.

Change 1: Point to a zip file in above acreen shot. My release worked but it had not deployed any of my web site files to the Azure server. NONE, at all.

Change 2: Point to another file CustomerPortal.SetParams.xml

(Note: at this point I was just trying random file to try and get anything to work) My release worked but nothing happened with regard to tokenisation.

Here is part of my log: enter image description here

As you can see, all my files from my website are not there even though the release was successful: enter image description here

enter image description here

Any help would be appreciate.

RuSs
  • 1,725
  • 1
  • 29
  • 47
  • While replacing token should work, xml transformation seems the more appropriate approach in your case. – mbx Sep 05 '16 at 08:46

3 Answers3

4

There is no built-in token replacement in the VSTS Release Management. Injecting values into a web.config is a deployment task, and VSTS Release Management is deployment tool agnostic.

If you need to inject values into configuration files (or otherwise alter them) at the time of deployment, that's something you can build into your deployment scripts.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Daniel, thanks for this. So what is the point of the configuration variables as shown in the second picture in my post? And note, I was able create my own custom variable called MyVar, so what can this configuration variable be used for if not for injecting values. – RuSs Feb 26 '16 at 01:31
  • It allows you to make a reusable parameters so you don't have to copy and paste values to your tasks. For example, you could create a `ServerName` variable, then use that variable as a parameter to several tasks within an environment, then override that value for a different environment without having to change the parameter provided to the task, and giving you only one place to maintain the actual parameter value. – Daniel Mann Feb 26 '16 at 01:33
  • ah, that makes sense. I only started using VSTS build system last week so still getting my head around it – RuSs Feb 27 '16 at 02:21
  • Moving from octopus deploy to VSTS release management, this is the biggest pain so far! – Michiel Cornille Aug 24 '16 at 08:24
4

There is currently no built-in task for replacing token values. You could either write a custom script to handle this or use one of the existing 3rd party task available, like eg the Replace Tokens task Colin's ALM Corner Build & Release Tools .

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
2

This can be tricky if you're coming from the older Release Management or the Web Deploy tasks that would replace tokens from Web.Release.config and replace lines in your normal web.config.

The solution I have implemented is to use two tasks; one task to replace the tokens of the Web.Release.config (not web.config because I want to run locally without hassles), and a second task to 'move' the Web.Release.config file over your web.config. I'm on windows servers so your implementation may need a tweak but the process would be similar.

IMPORTANT: Your Web.Release.config should be a full clone of your web.config, with the tokens in place. It cannot remain a partial config like it may have been when using the old web deploy transform functionality.

Using cmd.exe, the arguments are: cmd /c move /y "YOUR_BUILD\drop\YOUR_PROJECT\Web.Release.config" "YOUR_BUILD\drop\YOUR_PROJECT\Web.config"

enter image description here

enter image description here

Bill
  • 2,382
  • 2
  • 24
  • 27