Sunday, February 08, 2009

Web Packaging: Creating a Web Package using VS 2010

In the earlier post I highlighted various investments that we are making in Visual Studio 2010 and IIS to make Web Deployment easier.  You can read that post below:

Deploying a web project with all its correct dependencies is not a trivial task. Some of the assets which need to be considered during deployment are:

  • Web Content (.aspx, .ascx, images, xml files, PDBs, Binaries etc)
  • IIS Settings (Directory browsing, Error pages, Default Documents etc)
  • Databases that the web project uses
  • GAC Assemblies and COM components which the web project depends upon
  • Registry Settings that may be used within the web project
  • Security Certificates
  • App Pools

In an enterprise environment a web application with all of its dependencies needs to move across various environments before being finally being deployed to a production server.  A typical set of transition servers are development, testing/QA, staging/pre-production and production.  Also on the production environment there are web farms where these webs need to be replicated.  Today doing all these things is more or less a manual process and involves a tons of documentation that both developers and server admins have to deal with.  Even with all the documentation the steps are certainly very much prone to errors.

To aid all these scenarios we are introducing the concept of  a "Web Package". Web Package is an atomic, transparent, self describing unit representing your web which can be easily hydrated onto any IIS Web server to reproduce your web.  VS 2010 uses MSDeploy  to create the web package from your web application.

In today's post I will be primarily focusing on creating a web package from VS 2010 which has IIS Settings as well as web content.

The package created by VS can be installed using UI in IIS Manager as well as command line, we anticipate that developers eventually will give the web packages to server administrators who will be able to inspect/verify the package and then install them on the server...  I will cover package installation topic in subsequent post...  But for now let us learn how to create a web package

Step 1: Configure your Web Application Project (WAP) to use IIS Settings

For this discussion we have BlogEngine.Web downloaded from codeplex and converted it into a WAP.  Then this project was opened in VS 2010  and the VS10 migration wizard moved the project into VS10 format.  Thanks to the multi-targeting  features in VS 2010 which can support .NET versions 2.0 till 4.0; hence it is up to you which Framework version you want to run your web against.    I have also configured this blog application to use IIS Web Server for development (Learn how to do so by clicking here). 

At the end of this step my solution explorer looks as below:


Step 2: Configure IIS Settings in IIS Manager

Most IIS 7 web applications use IIS integrated pipeline which is configured with "Default App Pool" of IIS.  Blog Engine .web does not use integrated mode and will throw an error shown below if made to run under "Default App Pool".


To get rid of this error I changed the App Pool of this application to "Classic App Pool" (Learn how to do so by clicking here) and then the application runs great as shown below:


App Pool mapping is just one of the IIS setting which your app may use, there are various other IIS Settings which you can configure using IIS Manager (e.g. Default document, Error pages etc etc); all of these settings are relevant based on your application scenario... The good news is that VS 10 & MSDeploy will auto detect all the changes you make to the default IIS settings and pick it up for deployment...

Essentially, at the end of this step you should have your web application up and running with all the IIS settings configured in IIS Manager. 

Step 3: Configure Package Settings

In VS 2010 we have introduced one additional property page for WAPs called "Publish" as shown below:


Let us look at various properties of the this tab to understand how it works:

Configuration Aware Tab: Note that the Publish tab is build configuration aware:


  • The Publish tab is made configuration aware as deployment settings tend to change from environment to environment; for e.g. many a times developers want to deploy their “Debug” configuration on a Test Server and include PDBs as part of this deployment. When the same web is deployed in “Release” configuration on a production server the deployment may exclude PDBs.  (Learn how to manage build configurations by clicking here)

Items to Package/Publish – This section will help you decide what type of content you would really like to package/deploy.

  • Types of Files: By default this option is set to "Only files needed to run this application" .  This is usually sufficient for your deployment as it includes all the files from your project except source code, project files and other crud files not required to be deployed...  But apart from that there are two additional options available as shown below...


"All files in this project" and "All files in this project folder" options are very similar to what Publish WAP options were in VS 2008...  I had written an earlier post explaining these options here...  In subsequent posts I will also dig into various other interesting ways of using these options.

  • Exclude Files from App_Data folder – “App_Data” folder is a special ASP.NET folder where many developers like to put their SQL Express DBs (.mdf/.ldf files), XML files and other content which they consider Data. In many situations on production web server a full version of SQL Server is available and using SQL Express is not all that relevant. In such scenario (and for the corresponding build configuration e.g “Release” ) a user can check the “Exclude Files from App_Data”. image
  • Exclude Generated Debug Symbols – It is important to understand that generation of debug symbols is different from deployment of the same. This check box will tell VS 10 whether you would like to package/deploy the already generated Debug Symbols (Learn more about deploying debug Symbols here). 

Package Items


  • IIS Settings  - Checking this checkbox informs VS10 that you are ready to take all of your IIS Settings configured for your application in IIS Manager as a part of your web package.  I am glad to tell you that IIS 5.1, IIS 6 as well as IIS 7 environments are supported as part of this feature hence whether you are working on XP, Win2K, Win2K3, Vista or Win2K8 you should have no issue with packaging IIS Settings...  

These setting includes the "App Pool mapping" your web is configured to run against (e.g. "Classic App Pool" mapping discussed in Step 2)

  • Additional Settings -   The items in this grid are advanced properties.  It is still good to know about these coz it impacts what will be included in your package.  Most of the properties in this grid are related to the entire server and not just to your application so you should use them very carefully. 

Currently VS10 only displays "Application Pool Settings" but behind the scene it is possible to configure VS10 to support packaging root web.config, machine config , security certificates, ACLs etc...  

I wrote a small tips & trick about differences between Application Pool Mapping and Application Pool Settings which will help clarify the implications of such advanced settings; you can read more about it here.

Package Settings


  • Create MSDeploy Package as a ZIP file - This checkbox allows you to decide whether you would like to create your web package as a .zip file or as a folder structure. If you are concerned about the size and are moving the web package around very often then I can see you using .zip format for the package; on the other hand if you care to compare two packages using diff commands (either of source control or independently) then I can see you using the folder format.
  • Package Location - This is an important and required property as it defines the path at which Visual Studio will place your web package. If you choose to change this path make sure that you have write access to the location. Do note that the Package Location is modified based on whether you choose to create the web package as a .ZIP file or vs a folder structure.
  • Destination IIS Application Path/Name - This property allows you to give IIS Application name that you will use at the destination Web Server.
  • Destination Application Physical Path - One of the most important information which is embedded inside the web package is the physical location where the package should be installed. This property allows you to pre-specify this embedded information.  You will have an opportunity change both IIS Application Physical Path as well as Application Name at the time of deployment but in this property page you are given an opportunity to choose a default value.

Step 4: Create the "Web Package"

This is the last step in creating the web package and the simplest too...  The idea is that once you configure the above settings creating a package should be easy; in fact even if you do not go to the "Publish" tab we have tried to set smart defaults so that in most normal circumstances creating web package should be just the below two steps:


  • Right Click on your "Project"
  • Click on Package --> Create Package

Once you click on this command you should start getting output messages around your package creation pumped into your output window... 

When you see “Publish Succeeded” as below in the output window then your package is successfully created.



To access the package go to the location specified in the “Package Location” textbox. By default this is in obj/Configuration/Package folder under your project root directory (Configuration here implies Active Configuration like Debug/Release etc).


Note: "Create Package" command creates web package only for Active configuration. By default “Debug” is the active configuration inside Visual Studio. If you would like to change the Active configuration you can do so by using Build --> Configuration Manager as described here. You can certainly set properties for all available configurations by switching the configuration on top of the “Publish” tab but that action does not change the Active configuration


Finally, you can also automate creation of web packages via your team build environment as everything discussed above is supported via MSBuild Tasks.  In subsequent posts we will get into the details of these areas too...

Hope this helps...


Nilesh Gamit said...

Hi Vishal... Nice post. I want build same thing for PHP/Apache/Linux environment. Do you know something is already available? or Any specific comments? Thanks in advance.

vairam v said...

The build options doesn't have option to include both debug & release when I create a package.
Hence, when deploying the admin can choose which one to deploy, dev(debug), QA & Prodc(Release).
Is there a way to do it, ie to make multiple builds in one package?

vairam v said...

Is there a way to save or import the exported application information tagged with an WAP even when it is mapped to visual studio web dev server run locally on my machine to a configuration profile.

DimDragon said...

Hello Vishal, I have one question. I have read and actually tried all this in VS 2010 B2 however when you create the package, final msdeploy usage is such that it can't actually create new website outside "Default Web Site" on IIS 6.0. I have seen however that Web Platform Installer 2 given similar package with just ProviderPath parameter has the UI to select new website and it works on IIS 6.0 flawlessly. Do you happen to know what kind of code/scripting is used in WPI ( which claims to be based on msdeploy completely ) ? I have an idea to use runCommand provider to create website on IIS 6.0 but this suggests internal logic in package which should be stripped of such things as ultimate goal. Thx in advance for your output.

Regards Dimitar

Acai Max Cleanse said...

Im glad to see that people are actually writing about this issue in such a smart way, showing us all different sides to it.

Anonymous said...

I am confused by "For this discussion we have BlogEngine.Web downloaded from codeplex and converted it into a WAP. Then this project was opened in VS 2010 and the VS10 migration wizard moved the project into VS10 format." How did you convert it into a WAP prior to opening it in VS 2010?

Vishal R Joshi said...

The conversion was done manually by our QA team as we wanted to test early on. Changing page directives adding project file etc. :-)

Steve Dunn said...

We are successfully generating our deployment package, which includes the IIS settings to pickup the app pool, etc. But we are also using the serviceAutoStartProvider feature in IIS 7.5, which is getting set correctly for the application in the package, but not actually being created.

Short of adding a postSync command to test for and create the serviceAutoStartProvider, is there a way to tell the wpp to include the serviceAutoStartProvider config setting?

Vishal R Joshi said...

Hi Steve,
I think for the timebeing the workaround might be hooking up runCommand provider of Web Deploy at the end of the sync and then writing extra information. Although I will try to get more information on this topic and get back to you if possible. Feel free to send me an email at and I can connect you with the team.

Chris | Social Marketing said...

I know your post is a bit old but is very informative, I had to make some changes to work on VS2010, but the theory remains solid. Thanks a concise and very well explain post about a new deployment option with VS.

Joseph said...

Hi Vishal,

Thanks for this post (series), they are clear and extremely helpful. However, I am running into an issue I am hoping that you can help with.

I have been unable to find a way to change the default value for the application pool name. Every time I create a Deployment Package the parameter: "IIS Web Application Pool Name" in the SetParameters.xml file is always "ASP.NET v4.0".

I am hoping to to be able to change this based on the selected configuration. What am I missing?

Thanks in Advance,

Anonymous said...

hii every body a want to change the path folder for example D:\Projects\toto\toto in dev not change at production target machine msdeploy with .zip

Anonymous said...

Hi Vishal,

Thanks for the great article.
I am facing a problem related to app pool.
can we create and set dedicated app pool using parameters.xml file or using some other method.
I'm using (Use Visual Studio Development Server) in web tab.

Thanks in advance for help.

Sandeep Bhadauriya said...

Nice Article !!