.NET Installer Project Step-by-Step

In this article I will go through setting up a .NET installer project step-by-step for when you want to automate installation of a .NET Windows Forms Application. I’m assuming here that you have already put together your actual application and that you want to set up an installer for it now.

These steps are specific for Visual Studio 2010. If you are using an earlier or later version of Visual Studio, then the location of the menu options may vary slightly.

If you found this article interesting, please have a look at some of my other .NET articles.

Thoughts on Which Installer Project to Choose

Visual Studio 2010 supports two options for installer projects. These are:

  1. A Setup Project Installer
  2. A Setup Wizard Installer

The step-by-step example in this article covers creating a basic custom installer (Setup Project). However the options are similar for an installer project created using the installer Wizard setup (Setup Wizard), after the Wizard has finished generating the project for you.

Starting your installer by using the custom installer gives you more granular control over how your installer functions and the setup requires about as much effort as the Wizard. Because it is so easy to put together a custom installer and because it gives you much more granular control over what happens during the installation, I really suggest setting up your installer yourself instead of using the Setup Wizard. It’s really just a matter of personal preference though.

Steps to Set up Your Installer Project

  1. Right-click on your solution in solution explorer
  2. Then select Add –> New Project
  3. Expand Other Project Types
  4. Expand Setup and Deployment
  5. Select Visual Studio Installer
  6. Select Setup Project and give it an appropriate name in the name field at the bottom of the wizard.
  7. *Note: give your setup project a name that you would like it to appear as on the end-user’s computer. Don’t name it something like SetupAbc… instead use a descriptive name like your project’s name.
  8. Click OK
  9. * The new project should now appear below your Windows Application project

You can check that your project is properly added by:

  1. Clicking Project in the top menu bar
  2. Selecting Project Dependencies
  3. In the popup that appears, make sure the projects you want included are checked. You can also set the build order for your projects in the Build Order tab.
  4. Select OK to save the dependencies.

Adding your Windows Form Assemblies to your Setup Project

  1. Click Application Folder in the Setup Project
  2. Right-click in the main window and select Add –> Project Output
  3. Make sure Primary Output is selected. This will include the DLL or EXE from your main project.
  4. Click OK 
  5. Ensure that in the Solution Explorer of the Install Project that you see a folder called Detected Dependencies and that it contains the Microsoft .NET Framework.

Choose to add your new application to the end-user’s Desktop and/or Programs Menu

  1. Click User’s Desktop under File System on Target Machine.
  2. In the main content pane right click and select: Create New ShortCut
  3. Select Application Folder (which you set up in a previous step to hold your application’s assemblies)
  4. Click OK
  5. Select the Primary output from [your Windows Form Project Name]
  6. Click OK
  7. Give your new ShortCut a descriptive name that your end-users will recognize as your application.

When you are ready to test your installer project:

  1. Right Click on your Installer Project in the Solution Explorer Window
  2. Select Build
  3. The Compiler Output pane at the bottom of Visual Studio will show you if the build was successful, and the directory in which to find the .msi installer file.

Testing a Mock Installation of Your New Application:

  1. Browse to the output directory of your installer project (you can find this in the Compiler Output pane at the bottom of Visual Studio after a successful build)
  2. Make sure you have both a .msi and a Setup.exe file
  3. Copy both files to a folder on your hard-drive
  4. Test the installation by double-clicking the Setup.exe file.
  5. Go through the installation wizard for your application. At the end of the installation make sure that your Windows Application is now properly installed on your system.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s