Profile
How to modify Web. config when TFS online compiles automatically
ref:https://dustinoprea.com/2016/05/06/using-tokenization-token-replacement-for-buildsreleases-in-tfs-2015/
Steps
Install release Management Utility tasks
Https://marketplace.visualstudio.com/items?itemName=ms-devlabs.utilitytasks
Add Tokenizer into BuildStep
http://blogs.blackmarble.co.uk/blogs/rfennell/post/2016/03/01/ A-vnext-build-task-and-powershell-script-to-generate-release-notes-as-part-of-tfs-vnext-build
Write the Webconfigreplace.json and submit it to TFS
{" default": {" customvariables": { "Variable1": "Value1", "Variable2": "Value2" }, " Configchanges ": [ { " KeyName ":"/configuration/metamodel ", " Attribute ":" ConfigSource ", " Value ":" Config\\metamodel.config " }, { " KeyName ":"/configuration/connectionstrings ", " Attribute ":" ConfigSource ", " Value ":" Config\\connectionstrings.config " } , { " KeyName ":"/ Configuration/runtime/assemblybinding/probing ", " Attribute ":" PrivatePath ", " Value ":" BIN;BINMP;BINQF " } , { "KeyName": "/configuration/system.web/compilation", "Attribute": "Debug", " Value ': ' False ' } ]}}
Note: The default is environment name here, and if environment name is not configured, specify default to
Configuring the configuration Json FileName: $ (Build.Repository.LocalPath)/src/xxx/webconfigreplace.json
Note that you must use the $ (Build.Repository.LocalPath) variable here to get the file root path.
Also, to replace a tag in Web. config with a variable in the _XXX_ format, the variable does not support system internal variables to use system built-in variables, such as $ (build.sourceversion)
You can create a new user variable and set its value to $ (build.sourceversion)
TFS Online Build change web. config