I wanted to jot a couple notes about the process which took me a few minutes to figure out.
Step 1 is setup and configure Package/Publish Settings.
- Open Visual Studio 2010
- Open your Web Project
- Open Solution Explorer
- Right-Click on your Web Project
- Click on Package/Publish Settings
At this point, you should see the below.
You need to make sure you set the “IIS Web site/application name to use on the destination server” to the «Web Site»/«Virtual Directory» path. If you are updating a Web Site just leave it to be the web site name in IIS.
This is very important. If this doesn’t match the target, then your deployment will fail unless you customize the deployment further.
You’ll want to repeat this process for all your difference Configurations. By default, Visual Studio gives you Debug and Release. Most people, will add one per environment to the list (i.e. Development, Integration, QA, Staging, Production, etc.)
Step 2 add a Parameters.xml file to the root of your Web Project in Visual Studio 2010. This allows you to setup parameters, which the deployment process will use when it’s processing your deployment. An example of what I used is below.
You’ll note I used $(DeployIisAppPath) several times within the file. This refers back to the “IIS Web site/application name to use on the destination server” setting in your Package/Publish Settings in your Web Project.
Note: At the point of this writing, I haven’t experimented much with these settings, so feel free to tweak away.
Step 3 create your package. The simple way is to right-click your Web Project in Visual Studio and click Build Deployment Package.
This will create the package in the folder you set in the Package/Publish Settings for your Web Project.
You can use MSBuild from the command line. This comes in handy when you want to setup a build server to execute the Build and Package processes. The command line parameter looks like the below.
\msbuild" .\MyWeb\MyWeb.csproj /t:Build,Package /p:Configuration=Release;DesktopBuildPackageLocation=C:\output\MyWeb-Release.zip
It’s import to note a couple things about the above command line.
- I’m running on 64-bit Windows, so my Framework folder is Framework64. You might need to change this if you’re running 32-bit Windows.
- I’m telling msbuild to run Build and then Package with the /t argument. Case sensitive.
- I’m telling msbuild which configuration to run with /p argument.
- I’m telling msbuild where to put the package by specifying the DesktopBuildPackageLocation with the /p argument.
Feel free to tweak this away it was hand to get something going on my side and may or may not be helpful to you.
After you run either of the above, you should have a package zip file and several other files in the directory.
Note: If you copy the package zip around you must include the other files with it to get the deploy to work correctly, so don’t forget them.
Step 4 is go to your IIS target server and setup the Web Site or Virtual Directory. Ensure you setup the name of the Web Site or Virtual Directory to match the one you populated in the Package/Publish Settings in your Web Project.
You will need to ensure you .NET Framework version is configured on your Application Pool to match your web sites target framework.
Note: The web deployment does not initially create the Web Site for you on the destination server. This must be done by other means.
Step 5 ensure the destination server has the Web Deployment Tool installed and configured properly.
By default, the Web Deployment Remote service is Disabled and stopped on the server. You must enabled it and start it.
Step 6 follow these instructions on how to install a package using the included CMD file.
Voila! You have from start to finish setup and running with Visual Studio 2010 and Web Deployment Tool process.