【问题标题】:VS2010 Build Deployment Package + sectionGroup/custom settings + SetParameters.xmlVS2010构建部署包+sectionGroup/自定义设置+SetParameters.xml
【发布时间】:2011-09-02 20:52:38
【问题描述】:

几个月来,我一直在使用 Visual Studios 2010 的“构建部署包”(简称 BDP)。它运行良好,并且满足了我们想要的基本要求。

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

我开始研究这个非常酷的转换网络配置,但我认为我并没有完全理解它。我可以让它执行 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 生成输出。 “标记化”参数。

现在,我知道我并没有完全理解这一点,但我似乎找不到任何人使用自定义配置用于项目引用的其他程序集的任何示例。几乎所有示例似乎都与连接字符串和其他常见的 web.config 项有关。

我能找到的最接近我正在尝试做的事情是http://sedodream.com/2010/11/11/ASPNETWebApplicationPublishPackageTokenizingParameters.aspx 但是它只是关于连接字符串,而不是我想要设置的其他程序集的自定义设置参数。我想为 web.config 中的任何内容创建这些令牌。

所以,我的问题是:我们如何配置转换器配置文件,以便 BDP 可以生成带有额外 setParameter 节点的 SetParameters.xml,用于 web.config 中的自定义配置?

【问题讨论】:

  • 在花了这么多时间写完这篇文章之后,我可能已经找到了我的问题的答案。有趣的是,您如何研究如何提出问题,然后答案就出现了。 vishaljoshi.blogspot.com/2010/07/…

标签: msbuild msdeploy web-deployment-project web-deployment web-project


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2012-04-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多