2016-11-09 91 views
1

我想將本地web.config文件的appsettings部分從本地開發工作的一組單個設置轉換爲configSource文件路徑屬性,以便發佈到客戶端服務器。Web.Config將各個AppSettings轉換爲ConfigSource

基本上從該:

<appSettings> 
    <add key="setting1" value="devVal1"></add> 
    <add key="setting2" value="devVal2"></add> 
    <add key="setting3" value="devVal3"></add> 
</appSettings> 

這樣:

<appSettings configSource="clientSettings.config" /> 

該部分解決方案增加了configSource屬性。

<appSettings xdt:Transform="SetAttributes(configSource)" configSource="clientSettings.config"/> 

但我不知道如何刪除所有個人設置,以及(我認爲configSource無論如何都將覆蓋他們,但我寧願沒有他們也沒有,以避免無關dev設置在我的客戶端的每個web.config文件

回答

3

有點更多的毅力導致我的答案。將「RemoveAll」轉換應用於appSetting內的add元素。

<appSettings xdt:Transform="SetAttributes(configSource)" configSource="clientSettings.config"> 
    <add xdt:Transform="RemoveAll"/> 
</appSetting> 

希望這是在未來使用的人的(如果僅僅作爲爲什麼你應該做額外的工作,60分鐘即可降到了「提問」按鈕前一個例子)...