4

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?

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, Richard. We're using VS2010, unfortunately. But I just took a quick look through the Microsoft.Web.Publishing.targets file, and I can't see why the same solution wouldn't work. I should note that I'm looking at it on a build server, which only has a Visual Studio Shell on it. All of the build/deploy is done by calling MSBuild with a custom build script.
Yup, it works on my VS2010 RTM, too. I put this into my project files and it worked like a charm. Finally! Thanks!
FYI, the best way to find out new stuff like this is to search through %programfiles%\msbuild\Microsoft\VisualStudio\v11.0\Microsoft.Web.Publish.targets for the nearest thing you know about ("Parameters.xml") in this case.
Update: targets file is at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets" in VS 2010 SP1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.