You are currently offline, waiting for your internet to reconnect

Running a deployment package with quoted parameters fails in Visual Studio 2010 Service Pack 1

Consider the following scenario.  Using Visual Studio 2010 SP1, you create a Web Application Project.  You then create a deployment package from the Build --> Deployment Package menu for that project. You attempt to run the deploy.cmd file by passing quoted parameters to the deploy script. For example, you try to run a command with syntax similar to the following:

MyWebProject.deploy.cmd "-setParam:testvalue='my parameter',value='test'"

When the command is run, the deployment fails.  This problem does not occur in the release version of Visual Studio 2010.

In the initial release version of Visual Studio 2010, any quotes in the parameters passed to the <ProjectName>.deploy.cmd batch file generated as part of creating a WebDeploy package would be stripped prior to the command being run.  In Visual Studio 2010  SP1, a change was made in the manner command line arguments are passed to the deployment script: Any quotes in the parameters do not get stripped before the deployment script is run.  This causes WebDeploy to be unable to parse the additional parameters correctly, and the deployment fails.

To work around this behavior, choose one of the following options:
  1. Create a SetParameters.xml file and use the _MsDeployAdditionalFlags environment variable for it to get used.
  2. Replace Microsoft.Web.Publishing.targets with the new version

Further details about each workaround are provided in the More Information section below.

Solution 1: SetParameters.xml + _MsDeployAdditionalFlags

With this solution you create a new file which will contain the parameter values which will be used when you deploy your application using the .cmd file. Here is an example of such a file:

<?xml version="1.0" encoding="utf-8"?><parameters>  <setParameter name="IIS Web Application Name"                 value="Default Web Site/CustomWebApplication1" />  <setParameter name="ApplicationServices-Web.config Connection String"                 value="data source=data source=StagingServer;Initial Catalog=AppServices;Integrated Security=SSPI;" /></parameters>

In this XML file you will have a setParameter element for every parameter value. Each of these setParameter elements should have both a name and value attribute. After this has been set, set the _MsDeployAdditionalFlags environment variable in order for this to be picked up when you execute the .cmd file. Following is an example of this workaround run from a command prompt along with the expected output:

C:\>set _MsDeployAdditionalFlags=-setParamFile:"C:\Temp\_NET\Web\QuoteIssue\WebApplication1\Custom.SetParameters.xml" C:\>C:\Temp\_NET\Web\QuoteIssue\WebApplication1\WebApplication1\obj\Debug\Package\WebApplication1.deploy.cmd /Y=========================================================SetParameters from:"C:\Temp\_NET\Web\QuoteIssue\WebApplication1\WebApplication1\obj\Debug\Package\WebApplication1.SetParameters.xml"You can change IIS Application Name, Physical path, connectionStringor other deploy parameters in the above file.-------------------------------------------------------Start executing msdeploy.exe-------------------------------------------------------"C:\Program Files\IIS\Microsoft Web Deploy V2\\msdeploy.exe" -source:package='C:\Temp\_NET\Web\QuoteIssue\WebApplication1\WebApplication1\obj\Debug\Package\' -dest:auto,includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\Temp\_NET\Web\QuoteIssue\WebApplication1\WebApplication1\obj\Debug\Package\WebApplication1.SetParameters.xml" -setParamFile:"C:\Temp\_NET\Web\QuoteIssue\WebApplication1\Custom.SetParameters.xml"Info: Adding sitemanifest (sitemanifest).Info: Updating createApp (Default Web Site/CustomWebApplication1).Info: Adding contentPath (Default Web Site/CustomWebApplication1).Info: Adding dirPath (Default Web Site/CustomWebApplication1).Info: Adding child filePath (Default Web Site/CustomWebApplication1\About.aspx).Info: Adding child dirPath (Default Web Site/CustomWebApplication1\Account).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Account\ChangePassword.aspx).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Account\ChangePasswordSuccess.aspx).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Account\Login.aspx).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Account\Register.aspx).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Account\Web.config).Info: Adding child dirPath (Default Web Site/CustomWebApplication1\bin).Info: Adding child filePath (Default Web Site/CustomWebApplication1\bin\WebApplication1.dll).Info: Adding child filePath (Default Web Site/CustomWebApplication1\bin\WebApplication1.pdb).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Default.aspx).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Global.asax).Info: Adding child dirPath (Default Web Site/CustomWebApplication1\Scripts).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Scripts\jquery-1.4.1-vsdoc.js).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Scripts\jquery-1.4.1.js).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Scripts\jquery-1.4.1.min.js).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Site.Master).Info: Adding child dirPath (Default Web Site/CustomWebApplication1\Styles).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Styles\Site.css).Info: Adding child filePath (Default Web Site/CustomWebApplication1\Web.config).Info: Adding setAcl (Default Web Site/CustomWebApplication1).Info: Adding setAcl (Default Web Site/CustomWebApplication1).Total changes: 26 (25 added, 0 deleted, 1 updated, 0 parameters changed, 538189 bytes copied) C:\>

From the command executed you can see that the -setParamFile value was successfully passed through to the MSDeploy command.

Solution 2: Replace Microsoft.Web.Publishing.targets

In this solution you perform the following steps:

  1. Backup your copy of Microsoft.Web.Publishing.targets file
  2. Copy the new Microsoft.Web.Publishing.targets file to the correct location
  3. Clean the impacted projects
  4. Rebuild the package

Step 1 - Backup your copy of Microsoft.Web.Publishing.targets

Before you replace your version of Microsoft.Web.Publishing.targets file it is suggested that you backup the current version in case you ever need to revert back to it. This file is located at the following location by default:

Computer Architecture --- Location
x86 (32 bit) --- C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
x64 (64 bit) --- C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets

Step 2
- Copy the new Microsoft.Web.Publishing.targets file
Place the new file in the location identified above.

Step 3 - Clean the impacted projects
Since the underlying issue relates to how the .cmd file is generated we need to ensure that the .cmd file will be regenerated the next time you package your application. You can do this in two ways:

  1. In Visual Studio (or via command line) perform a Clean for the project
  2. Delete the obj\ folder for the project

Step 4 - Rebuild the package
From Visual Studio or from the command line, package the application again.


Solution 3: Use new targets provided by Microsoft

New Microsoft.Web.Publishing.targets are stored here:

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 2537134 - Last Review: 04/19/2011 19:50:00 - Revision: 4.0

Microsoft Visual Studio 2010 Service Pack 1

  • KB2537134