3

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

2
  • 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. Commented Aug 1, 2012 at 14:13
  • The .cmd file is working. Thanks for pointing me to that. I guess I got off the beaten path. Commented Aug 1, 2012 at 14:33

1 Answer 1

2

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.

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

Comments

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.