How do you parameterize deployments when using ASP.NET 4.5 publish profiles?
Asked Answered
H

1

6

The new pubxml files in ASP.NET 4.5 are definitely a step in the right direction. I also like msdeploy's support for parameters.xml files (even though they are sometimes not as powerful as I would like). Now, how do I combine msdeploy's parameters and the pubxml files? I would expect that the pubxml files would allow me to provide a setting like

<ParametersFile>productionParameters.xml</ParametersFile>

or something similar in my production.pubxml file, that would contain values to be merged into web.config when publishing to the production environment. Is that possible or do I have to go back to rolling my own way of determining the parameters file and invoking msdeploy with -setParamFile="productionParameters.xml"?

Hammering answered 23/10, 2012 at 12:19 Comment(0)
H
12

You can't set your own parameters file, but you can declare parameter values from within the pubxml:

<ItemGroup>
  <MSDeployParameterValue Include="Parameter Name">
    <ParameterValue>Parameter Value</ParameterValue>
  </MSDeployParameterValue>
</ItemGroup>
Hypoderm answered 23/10, 2012 at 22:47 Comment(3)
Thank you for your time. Sorry, I don't quite follow. If I declare a parameter like that, what happens - are they only used by the publishing wizard or can I have them merged into web.config? After being declared here, where are they actually used?Hammering
The above syntax is the assignment and is different for each Publish Profile. If you need to declare additional parameters (beyond the auto-generated parameters for connection strings and IIS Application), you can either define them in wpp.targets with <MsDeployDeclareParameters> or add a Parameters.xml to the root of your web application and anything defined in there will be merged with the auto-generated ones.Hypoderm
This technique doesn't seem to override defaults set in Parameters.xml. I had to redeclare the parameters, with defaults, with a priority that superseded Parameters.xml as described here.Wallack

© 2022 - 2024 — McMap. All rights reserved.