I'm trying to update a web.config app setting called 'AppVersion' with the build number when building my application in VSTS.
Here are my build steps:
The 'Replace tokens' step converts any variables you set for your build and replaces the tokens you've set in your config files. This part works but what it won't do is get an environment variable like the build number and do a replace. It will just replace whatever text has been specified. Here's my build variables:
So after the build step is completed, my app setting is...
<add key="AppVersion" value="$(BuildNumber)" />
when it should be something like...
<add key="AppVersion" value="20160520.1" />
Can anyone point me in the right direction? Many thanks.
I did something similar using the "Replace Tokens in **/*config" task.
To update the value for the key "AppVersion" with the current build number, your line should look like the following,
<add key="AppVersion" value="#{Build.BuildNumber}#" />
You can add a PowerShell script task before "Replace Token" task to pass the "BuildNumber" to "AppVersion" variable as following.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With