Msbuild VS2010构建部署包+;节组/自定义设置+;SetParameters.xml

Msbuild VS2010构建部署包+;节组/自定义设置+;SetParameters.xml,msbuild,msdeploy,web-deployment-project,web-deployment,web-project,Msbuild,Msdeploy,Web Deployment Project,Web Deployment,Web Project,几个月来,我一直在使用VisualStudio2010的“构建部署包”(简称BDP)。它工作得很好,满足了我们的基本要求 我决定更进一步,弄清楚如何获取自定义配置,以便在BDP生成的Project.SetParameters.xml文件中对其进行修改。我们使用它的方式是构建这个部署包,并将其交付给客户服务器。每台服务器可能不同,因此我们将SetParameters.xml保留在服务器上,并在以后升级时替换zip文件。我们使用WebDeploy工具使用构建部署包创建的cmd文件来部署它 我开始使用

几个月来,我一直在使用VisualStudio2010的“构建部署包”(简称BDP)。它工作得很好,满足了我们的基本要求

我决定更进一步,弄清楚如何获取自定义配置,以便在BDP生成的Project.SetParameters.xml文件中对其进行修改。我们使用它的方式是构建这个部署包,并将其交付给客户服务器。每台服务器可能不同,因此我们将SetParameters.xml保留在服务器上,并在以后升级时替换zip文件。我们使用WebDeploy工具使用构建部署包创建的cmd文件来部署它

我开始使用这个TransformWeb配置,它非常酷,但我认为我还没有完全理解它。我可以让它执行web.config中正常的项目(如连接字符串、web服务器设置等),但是我无法让它为web.config中包含的其他DLL的配置部分生成参数。例如:

比如说。假设这是引用多个其他程序集的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>

不过,这同样只是关于ConnectionString,而不是我要设置的其他程序集的自定义设置参数。我想为web.config中的任何内容创建这些令牌

那么,我的问题是:如何配置transformer配置文件,以便BDP可以为web.config中的自定义配置生成带有其他setParameter节点的SetParameters.xml?

这也是一本好书:


这就是我要找的。希望这能帮助别人

在花了那么多时间写下这些之后,我可能已经找到了我问题的答案。有趣的是,你是如何研究如何提问的,而答案就在眼前。
<?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>
    <?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>