Udostępnij za pośrednictwem


Visual Studio 2010 : How to deploy a Web application with Web Application Project Deployment (Part 1)

In all project it’s a real nightmare to manage configuration files. In Silverlight projects like in web applications, you can take advantage of Web Application Project Deployment features of Visual Studio 2010. In this blog, I’ll explain you :

  • How to create a new configuration (part 1);
  • How to create package definition (part 1);
  • How to create package (part 1);
  • How to publish the application (part 1);
  • How to use transformation with web.config files (part 2);
  • Some more links on this subject (part 2).

In this post, I won’t explain SQL deployment.

Creation of a new solution configuration

Right click on your solution file in Visual Studio, select Properties, on the left tree view, select configuration.

image

After clicking on the button “Configuration Manager …”, another pop-up appears. In the left drop down list, select “<New …>”. The “<Edit …>” button is used to rename or remove a configuration.

image

In the new pop-up, enter the name of the desired new configuration. In this case, “Staging”. You can use the “Copy settings from:” to duplicate settings from a specific configuration.

image

By default, the selected configuration is the one just created (i.e. Staging).

image

To make appears the dedicated web.config in the web application, right click on the web.config and select “Add Config Transforms”, and the Web.Staging.config will be created.

image 

How to create the package definition

Right click on the web project and select “Properties”. Select “Package/Publish” tab.

image

This screen is used to configure you deployment. You can specifies what you really want to package : pdb files, App_Data folder, database, …

For Silverlight application, “Only files needed to run this application” in the Items to deploy drop down list also deploys xap files.

image

Than, you can define the Web Deployment Package settings.

How to create the package

Rebuild your application to view the resulting package, right click on the web application and select “Create Package”.

image

As in previous paragraph, we have kept the default settings, you can see that in the obj folder, Visual Studio has created a new folder named Staging with a lot of files.

image

A zip file (folder obj/Staging/Package) named like your web project is present. This files contains :

  • Configuration files used for deployment;
  • The code to deploy.

In the same folder, a cmd file is present.

How to publish the application

To deploy the package there is several way:

Visual Studio provides easy to use screens for deployment. Using Profiles is very great to store all publication locations depending on your server.

image

In this sample, I used a file system deployment on the c:\temp folder.