我一直在Visual Studio 2010中使用「構建部署包」(簡稱BDP)幾個月。它工作得很好,並且完成了我們想要的基本要求。VS2010構建部署包+ sectionGroup /自定義設置+ SetParameters.xml
我決定更進一步瞭解如何獲取自定義配置,以便在BDP生成的Project.SetParameters.xml文件中對其進行修改。我們使用這種方式是我們構建這個部署包,並將其交付給客戶服務器。每個服務器可能都不相同,因此我們在服務器上保留SetParameters.xml,並稍後替換zip文件以便升級。我們使用WebDeploy工具將它部署到由Build Deployment Package創建的提供的cmd文件中。
我開始研究這個變化的web配置,這是非常酷的,但我不認爲我完全得到它。我可以讓它做在web.config內正常的項目(例如連接字符串,Web服務器設置等),但是我不能爲我的生活得到它生成參數的配置部分是其他DLL的一部分包含在web.config中。例如:
例如。說這是對於web項目引用其他幾個組件的web.config文件:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SomeAssembly.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<SomeAssembly.Properties.Settings>
<setting name="ExportLocation" serializeAs="String">
<value>C:\MediaExports\</value>
</setting>
</SomeAssembly.Properties.Settings>
</applicationSettings>
</configuration>
和我的變壓器是:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SomeAssembly.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<SomeAssembly.Properties.Settings>
<setting name="ExportLocation" value="[MakeMeSetParameter.xml-Entry]" serializeAs="String" xdt:Transform="SetAttributes" xdt:Locator="Match(value)"/>
</SomeAssembly.Properties.Settings>
</configuration>
樣品project.xml中(而不是從上面的,但會產生什麼我的項目):
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="SomeIISNameHere" />
<setParameter name="SomeAssemblySetting-SomeDescriptionOddPlaceforit" value="TheValueToBePlaced" />
<setParameter name="SomeGeneratedValueIwant" value="TheNewMediaExportLocation"/>
</parameters>
我無法弄清楚要放什麼東西在變壓器web.config中,使其產生對Project.SetParameters.xml輸出。 「Tokenized」參數。
現在,我知道我沒有完全理解這一點,但我似乎找不到任何使用自定義配置的項目引用其他程序集的例子。幾乎所有的例子似乎都與連接字符串和其他常見的web.config項目有關。
最近我可以找到我想要做的是http://sedodream.com/2010/11/11/ASPNETWebApplicationPublishPackageTokenizingParameters.aspx但是它只是關於連接字符串,而不是我想要設置的其他程序集的自定義設置參數。我想爲web.config中的任何內容創建這些標記。
所以,我的問題是:我們如何配置轉換器配置文件,以便BDP可以爲web.config中的自定義配置生成SetParameters.xml和其他setParameter節點?
花了所有的時間寫這篇文章後,我可能已經找到了我的問題的答案。有趣的是,你如何研究如何提出一個問題,並且答案呈現出來。 http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html – TravisWhidden