2016-06-30 88 views
2

我想問在Visual Studio Team Services構建過程中是否有人對Web API .config文件值進行了更改(用其他值替換)?有什麼最佳實踐或方法可以實現嗎?構建定義的配置值更新的最佳做法

+0

你的意思是'Web.Debug.config'和'Web.Release.config'?如果這是'app.config',你看過http://stackoverflow.com/questions/8082662/how-to-select-different-app-config-for-several-build-configurations? –

+0

我的意思是Web.config appSettings鍵值 – user2086174

+0

然後使用Web. {Build definition} .config'。 –

回答

0

您可以使用SlowCheetah根據您在構建隊列時指定的構建配置來變換配置文件中的值。

您還可以使用Replace Tokens任務來使用您在構建定義中創建的變量替換文件中的字符串。

0

你應該看看Web.configtransformations。您可以擁有一個主文件Web.config,然後根據文件Web.{Build definition name}.config中的內部定義名稱定義所需的轉換。這種轉化的

實施例:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <connectionStrings> 
     <add name="MyDB" connectionString="ReleaseSQLServer" 
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> 
    </connectionStrings> 
</configuration> 

將來自任何先前值ReleaseSQLServerMyDBconnectionString屬性。

+0

我如何通過(如果可能的話)VSO定義這些配置變量? – user2086174

+0

「VSO定義變量」是什麼意思? –

+0

我們可以在realese或構建定義下定義多個變量 – user2086174

相關問題