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, connectionString
or 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\P
ackage\WebApplication1.zip' -dest:auto,includeAcls='False' -verb:sync -disableLink:AppPoolExtension
-disableLink:ContentExtension -disableLink:Certifi
cateExtension
-setParamFile:"C:\Temp\_NET\Web\QuoteIssue\WebApplication1\WebApplication1\obj\Debug\Package\WebApplication1.SetPa
rameters.xml" -setPara
mFile:"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:
- Backup your copy of Microsoft.Web.Publishing.targets file
- Copy the new Microsoft.Web.Publishing.targets file to the correct location
- Clean the impacted projects
- 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:
- In Visual Studio (or via command line) perform a Clean for the project
- 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:
http://go.microsoft.com/fwlink/?LinkID=216789&clcid=0x409