VSTS Release - Define custom variable in web.config and set at release time

落爺英雄遲暮 提交于 2019-12-05 04:52:52

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"

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.

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 .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!