Web Deploy和Parameters.xml:如何在多个项目之间共享参数

时间:2022-02-05 11:13:00

I have a number of web apps in a suite. I use Web Deploy to publish the deployment packages that I build with Visual Studio. With these packages comes a SetParameters.xml file that can be used to modify values in the web.config. Several values are done automatically, such as connection strings, but one can add a parameters.xml file to a project in order to specify values that should be parameterizable:

我在套件中有很多网络应用程序。我使用Web Deploy发布我使用Visual Studio构建的部署包。使用这些软件包时,会出现一个SetParameters.xml文件,该文件可用于修改web.config中的值。自动完成多个值,例如连接字符串,但可以将一个parameters.xml文件添加到项目中,以指定应该可参数化的值:

 <?xml version="1.0" encoding="utf-8" ?>
     <parameters>
         <parameter name="Sharepoint service principal name"
                    description="The principal name of the Sharepoint service."
                    defaultValue="host/108.125.111.137">
              <parameterEntry kind="XmlFile"
                              scope="\\Web\.config$"
                              match="/configuration/system.serviceModel/client/endpoint/identity/servicePrincipalName/@value"/>
         </parameter>
    </parameters>

My question is: if all of my web apps have an app setting in web.config with the same key and value that I want to modify at deployment, how can I avoid duplicating the particular parameter in every parameters.xml file? Is there a way to put this tag in a single location and have each parameters.xml reference that common location instead?

我的问题是:如果我的所有Web应用程序在web.config中都有一个应用程序设置,并且我想在部署时修改相同的密钥和值,那么如何避免在每个parameters.xml文件中复制特定参数?有没有办法将此标记放在一个位置,并让每个parameters.xml引用该公共位置?

1 个解决方案

#1


6  

If you are using the VS2010 RTM Web Publishing, then no.

如果您使用的是VS2010 RTM Web Publishing,则不会。

However, if you are using VS2012 (or VS2010 + Azure SDK), you can simply define parameter files declaring an additional ParametersXMLFiles in your project file, wpp.targets or publish profile:

但是,如果您使用的是VS2012(或VS2010 + Azure SDK),则只需在项目文件中定义参数文件,声明其他ParametersXMLFiles,wpp.targets或发布配置文件:

<ItemGroup>
  <ParametersXMLFiles Include="$(SolutionDir)\CommonParameters.xml" />
<ItemGroup>

These would be merged with the Parameters.xml in each project's root and with any parameters declared in your "Package" publish profile using MsDeployDeclareParameters.

这些将与每个项目根目录中的Parameters.xml以及使用MsDeployDeclareParameters在“Package”发布配置文件中声明的任何参数合并。

#1


6  

If you are using the VS2010 RTM Web Publishing, then no.

如果您使用的是VS2010 RTM Web Publishing,则不会。

However, if you are using VS2012 (or VS2010 + Azure SDK), you can simply define parameter files declaring an additional ParametersXMLFiles in your project file, wpp.targets or publish profile:

但是,如果您使用的是VS2012(或VS2010 + Azure SDK),则只需在项目文件中定义参数文件,声明其他ParametersXMLFiles,wpp.targets或发布配置文件:

<ItemGroup>
  <ParametersXMLFiles Include="$(SolutionDir)\CommonParameters.xml" />
<ItemGroup>

These would be merged with the Parameters.xml in each project's root and with any parameters declared in your "Package" publish profile using MsDeployDeclareParameters.

这些将与每个项目根目录中的Parameters.xml以及使用MsDeployDeclareParameters在“Package”发布配置文件中声明的任何参数合并。