A practical example of using web application deployment package with IIS7

A practical example of using web application deployment package with IIS7

Rate This
  • Comments 2

When a zip package is built from VS2010 web application UI (via Build Deployment Package command), or through command line (msbuild myproject.csproj /t:package), a few files are generated in the destination folder. Here’s some brief description:

File Name Description
myApp.deploy-readme.txt Read me file of how to use myApp.deploy.cmd.
myApp.deploy.cmd The auto generated command file which can be used in many situations.  Check MSDN topic for details.
myApp.SetParameters.xml The parameter file that user can modify to affect deployed IIS application, such as IIS application name, connection string etc.  Check MSDN topic for more details.
myApp.SourceManifest.xml The source manifest file that VS uses to compile the package via web deploy.  Not useful after the package is generated.  But user can have a quick peek on what web deploy provider is used when generating package.
myApp.zip The package zipped file

 

It’s very common to deploy our package to a IIS7 virtual application under Default Web Site.  Since web deploy can generate a virtual application if it’s not exist, we can use the following options:

1. Manually import the zip file from IIS manager and change the “Application Path” in the “Import Application Package” Wizard.  (Import a Package through IIS Manager )

2. Change myApp.SetParameters.xml node value of parameter “IIS Web Application Name”:

<setParameter name="IIS Web Application Name" value="Default Web Site/test1" />

Then run “AppServer.cmd /y” from command line

3. In command line or batch file

Set _ArgMsDeployAdditionalFlags=-setParam:"IIS Web Application Name"="Default Web Site/test1"

AppServer.cmd /y

Set _ArgMsDeployAdditionalFlags=

4. One line command to deploy the package create virtual application under default web site:

"D:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:package=WebApplication4.zip -dest:auto -setParam:"IIS Web Application Name"="Default Web Site/test2"

 

Similarly, if we want to create a new website in IIS7 binding to a new port on a machine, name it AppServer, and deploy our package to it, we can use the following options:

1. Create the new website manually in IIS manager and import package from IIS manager.  All we need is the zip file on the machine.

2. In command line or batch file:

md D:\inetpub\wwwroot\AppServer

D:\Windows\System32\inetsrv\appcmd add site /name:AppServer /id:22 /bindings:http/*:8090: /physicalPath:D:\inetpub\wwwroot\AppServer

Set _ArgMsDeployAdditionalFlags=-setParam:"IIS Web Application Name"="AppServer"

AppServer.cmd /y

Set _ArgMsDeployAdditionalFlags=

Or make it a little bit fancy:

Set _ArgMsDeployAdditionalFlags=-presync:runCommand="md D:\inetpub\wwwroot\AppServer & D:\Windows\System32\inetsrv\appcmd add site /name:AppServer /id:22 /bindings:http/*:8090: /physicalPath:D:\inetpub\wwwroot\AppServer" -setParam:"IIS Web Application Name"="AppServer"

AppServer.cmd /y

Set _ArgMsDeployAdditionalFlags=

3. One line command to create a new web site in IIS and deploy package to it.  All we need is the zip file on the machine.

"D:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -presync:runCommand="md D:\inetpub\wwwroot\AppServer & D:\Windows\System32\inetsrv\appcmd add site /name:AppServer /id:22 /bindings:http/*:8090: /physicalPath:D:\inetpub\wwwroot\AppServer " -source:package=WebApplication2.zip -dest:auto -setParam:"IIS Web Application Name"="AppServer"

Hope this simple sample can generate more interest to use web deploy as packaging and deploying method.

 

Xinyang Qiu

Web Platform And Tools

Leave a Comment
  • Please add 1 and 8 and type the answer here:
  • Post
  • This is great. I had no idea that this was an option. I have always do everything manually and created my websites in IIS Manager and then moved over the files.

  • As a web designer i found this helpful too, thanks for this!

Page 1 of 1 (2 items)