我有2個.config文件必須配置。一個是web.config
,另一個是app.config
,這兩個文件都來自我們代碼運行的第三方供應商。所以我們需要對它進行調整,以便看到我們的代碼。從安裝程序更新第三方的.config轉換
我的計劃是使用xslt獲取我們的.config文件並將其合併到第三方文件中。
我已經看到了一些關於如何用msbuild來做這種事情的例子,但是由於我們現場正在做,我們將不得不使用安裝程序來做到這一點。任何幫助,將不勝感激。
例子: 我們開始接觸:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
自定義欄目
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="productName" type="company.productName, company, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" />
</configSections>
<productName defaultProvider="Provider1">
<providers>
<clear />
<add name="Provider1" type="Company.Product.Authentication.Provider1, Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" hostName="localhost:5555" />
<add name="Provider2" type="Company.Product.Authentication.Provider2, Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" hostName="demo.example.com" />
</providers>
</productName>
</configuration>
,結束時用:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="productName" type="company.productName, company, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" />
</configSections>
<productName defaultProvider="Provider1">
<providers>
<clear />
<add name="Provider1" type="Company.Product.Authentication.Provider1, Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" hostName="localhost:5555" />
<add name="Provider2" type="Company.Product.Authentication.Provider2, Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d9072a6c5128d57c" hostName="demo.example.com" />
</providers>
</productName>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
轉換隻是爲了將一個'配置'的子項複製到另一箇中嗎? – 2011-04-05 15:48:34
@Alejandro:這是正確的,檢查它是否存在,如果沒有添加它。如果是這樣,就讓它獨自一人。 – 2011-04-05 18:19:32
這不是我寫的。你需要弄清楚「檢查它是否存在」和「放棄它」的含義。 – 2011-04-05 18:23:33