Search code examples
asp.netxmliisparametersmsdeploy

Web Deploy and Parameters.xml: How to share parameters among multiple projects


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:

 <?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?


Solution

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

    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:

    <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.