TFS online build change web.config

概要

TFS online 自動編譯時如何修改web.configjavascript

ref:https://dustinoprea.com/2016/05/06/using-tokenization-token-replacement-for-buildsreleases-in-tfs-2015/java

步驟

安裝Release Management Utility tasksweb

https://marketplace.visualstudio.com/items?itemName=ms-devlabs.utilitytasksjson

 

將 Tokenizer 添加進BuildSteppost

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-buildui

編寫webConfigReplace.json,並提交到tfsspa

{
  "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便可debug

配置Configuration Json filename: $(Build.Repository.LocalPath)/src/XXX/webConfigReplace.jsonblog

注意,此處必須使用$(Build.Repository.LocalPath)變量獲取文件根路徑。token

 

另外,

1)若要使用_XXX_格式替換web.config 中的標記爲變量,變量不支持系統內部變量,若要使用系統內置變量,如$(Build.SourceVersion)

能夠新建一個用戶變量,而後設置其值爲$(Build.SourceVersion)

2)若config節點有namespace,則須要指定

{ "NamespaceUrl": "urn:schemas-microsoft-com:asm.v1", "NamespacePrefix": "asm", "KeyName": "/configuration/runtime/asm:assemblyBinding/asm:probing", "Attribute": "privatePath", "Value": "bin;binMP;binQF" }

相關文章
相關標籤/搜索