TFS online build change web.config
Posted jianyi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TFS online build change web.config相关的知识,希望对你有一定的参考价值。
概要
TFS online 自动编译时如何修改web.config
步骤
安装Release Management Utility tasks
https://marketplace.visualstudio.com/items?itemName=ms-devlabs.utilitytasks
将 Tokenizer 添加进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
编写webConfigReplace.json,并提交到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" } ] } }
注意:此处default为Environment name,若未配置Environment name,则指定default即可
配置Configuration Json filename: $(Build.Repository.LocalPath)/src/XXX/webConfigReplace.json
注意,此处必须使用$(Build.Repository.LocalPath)变量获取文件根路径。
另外,若要使用_XXX_格式替换web.config 中的标记为变量,变量不支持系统内部变量,若要使用系统内置变量,如$(Build.SourceVersion)
可以新建一个用户变量,然后设置其值为$(Build.SourceVersion)
以上是关于TFS online build change web.config的主要内容,如果未能解决你的问题,请参考以下文章
从 TFS 构建针对 Visual Studio Online 运行负载测试
Visual Studio Online (TFS) 中的累积流程图不正确
Git访问TFS出现权限不足(Using Personal Access Tokens to access Visual Studio Online)