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:
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=
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=
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"
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"
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"
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
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!