3
votes

I'm trying to use MSDeploy with the parameter settings file option so I can build once and deploy to multiple environments by overriding the parameters with different files. From PowerShell I'm calling msdeploy.

msdeploy.exe -verb:sync `
 -source:"contentPath='$SourceLocalPath'" ` 
 -dest:"contentPath='$TargetLocalPath',computername='$TargetServer'"
 -setParamFile:"$ParamFilePath" `
 -verbose

This results in an error about not recognizing parameters.

msdeploy.exe : Error: The declared parameter 'SqlConnString' is not recognized.

If I remove the "setParamFile" line, it deploys fine, but then uses default values. Also if I try to manually import the package from IIS, it displays the parameters with defaults filled in.

I have a Parameter.xml file in the root of the web project:

<parameters>
  <parameter name="SqlConnString" description="Please provide the SQL connection string" defaultValue="...;Initial Catalog=xxx;server=xxx;" tags="">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='Sql']/@connectionString" />
  </parameter>
</parameters>

The package is getting created with a ...SetParameters.xml file inside the package, which contains the entries from my Parameters.xml file plus the standard entries.

<parameters>
  <setParameter name="SqlConnString" value="...Initial Catalog=xxx;server=xxx;"/>
...  
</parameters>

Thank you

1
Have you tried using the .cmd file that is created by the packager? That is the way I've done this and haven't had any problems with it finding the parameters. - BNL
The .cmd file is working. Thanks for pointing me to that. I guess I got off the beaten path. - What Would Be Cool

1 Answers

2
votes

Try changing the value in "name" from "SqlConnString" to "YourSqlConnectionName-Web.config Connection String". If you want to know the exact name you have to look at your web.config file. The above example should work for a section like this in your web.config file:

  <connectionStrings>
    <add name="YourSqlConnectionName"
      connectionString="...;Initial Catalog=xxx;server=xxx;"
      providerName="System.Data.EntityClient"/>
  </connectionStrings>

So you should configure your setParameters.xml file like:

<parameters>
  <setParameter name="YourSqlConnectionName-Web.config Connection String" value="...Initial Catalog=xxx;server=xxx;"/>
</parameters>

and your Parameters.xml file like:

<parameters>
  <parameter name="YourSqlConnectionName-Web.config Connection String" description="Please provide the SQL connection string" defaultValue="...;Initial Catalog=xxx;server=xxx;" tags="">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='YourSqlConnectionName']/@connectionString" />
  </parameter>
</parameters>

Hope this solves your issue.