Your official information source from the .NET Web Development and Tools group at Microsoft.
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:
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:
Items to Package/Publish – This section will help you decide what type of content you would really like to package/deploy.
"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.
Package Items
These setting includes the "App Pool mapping" your web is configured to run against (e.g. "Classic App Pool" mapping discussed in Step 2)
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.
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
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:
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...
Vishal R. Joshi | Program Manager | Visual Studio Web Developer
In the earlier post I highlighted various investments that we are making in Visual Studio 2010 and IIS
Thank you for submitting this cool story - Trackback from DotNetShoutout
Now that's pretty cool.
Now if only we had a convenient way to deploy a different web.config for different environments, i.e. different connection string from development, staging to production.
Hi,
Very nice and descriptive article. I will be looking forward to see the continuation in this series.
Thanks,
Thani
You are voted (great) - Trackback from Web Development Community
My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Visual T4 Blog is a new blog focused on the T4 code generation tool that ships with VS2008. Here are the first few posts: New Blog
I am VERY excited about this addition to VS2010. I have very few complaints about VS2008 and this is the big one -- website deployment.
If you guys can get this right you'll have saved us a lot of time and agony.
Thank you for submitting this cool story - Trackback from progg.ru
>>Steve Sheldon: web.config for different environments
Vishal: Steve, we have a solution for that too... We are introducing web.debug.config, web.staging.config, web.production.config, web.testing.config based on VS configurations... I will write about this more in the future too but the overview post here covers it a tiny bit
http://vishaljoshi.blogspot.com/2009/02/web-deployment-with-vs-2010-and-iis.html
nice post, thanks for sharing!