November 14, 2006

dotNET - VS 2005 Web Deployment Projects + Installer (MSI) creation

You've got your Web Project in Visual Studio and you want to create a way to provide it as an installation.
There are 2 ways to do this:
1. Create a Web Deployment Project from your Web Project and then use the output of this as the input to another project, a Setup Project.
After you've achieved this you'll have an MSI installer file which has configurable elements, these configurable elements will be dictated by yourself when creating the Web Deployment Project and the Setup Project.
2. Create a WebSetup project from your Web Project.
After you've achieved this you'll have an MSI installer file.

Option 2 is the simpler option.
The difference between the 2 options is that the first provides extra control using the Deployment project, such things a MSBuild and assembly type deployment.

If you choose option 1 then:
  • You can quickly create a Web Deployment Project by right-clicking the Web Project in the Visual Studio Solution Explorer. This will copy the contents of your Web Project into the new Deployment Project. See the links below on how to customise the settings.
  • The Setup Project uses the Web Deployment Project, this is achieved by adding the Web Deployment projects output as a reference, Right Click on the Setup Project...
  • Notes:
  • I noted during the Web Deployment Project creation that;
  • Changing the Project Properties does not always apply e.g. I changed the Property Pages->Deployment section to "appsettings=appsettings.config", this indicates the appsettings section of the Websites web.config should be overridden with that in the appsettings.config file in the source Web Project. But the appsettings is case-sensitive, I fixed it but it still did not apply resulting in a compilation error, I had to edit the project file itself using the VS editor. The contents of the appsettings.config file is the complete appSettings section, including the appSettings tags.
  • The appSetting file is located in the original Web Project.
  • Using appSettings=appsettings.config in the Web Deployement Project's Property Pages->Deployment section it overrides the appSettings section.
If you choose option 2 then:
  • This is a much simpler solution and really just copies the contents of your Web project into an exe or msi file for later installation.
  • Create a Web Setup project from the File->New Project dialog, under Setup and Deployment.
  • Add the Web site project's Output as a reference in the WebSetup project.

For both option 1 and 2 you'll need to create some sort of Setup project, either a Setup project (Option 1. which uses the output of the Web Deployment project) or a Web Setup project (Option 2. which uses the Web project directly).
For more on both types of Setup project and how to use the user input see the article later in this blog dotNET - Setup Programs Installer creation using VS2005

Using Web Deployment Projects with Visual Studio 2005 (msdn)
ScottGu's Blog - VS 2005 Web Deployment Projects
Modifying Web.Config during Website Installation (AspAlliance)


Shree said...

We normally add the project output and content files to the Setup project.How do we pipe in the O/p of the Web Deployment project to Web set up project?Do we still ahev to add the project output and content files to the Setup project?

Shree said...
This comment has been removed by the author.
aparna john said...

Hi,One of the primary features of Web Design Cochin is the ability to use the cluster screen shown above to deploy a new version of an application in a way that can be reversed at the first sign of trouble. This method requires more instances to be in use during deployment, but it can greatly reduce the duration of service outages caused by bad deployments.Thanks........