How to Create an Installer with Microsoft Visual Studio

Introduction

Visual Studio 2010 contains a package that enables you to create Windows installer files for your applications. Follow these simple steps to build your own setup package for the Visual Studio application you are working on.

Creating an installer within your existing Visual Studio project

Start by adding an installer project by right-clicking on your solution folder and choosing Add -> New Project:

Then in the Add New Project dialog choose Visual Studio Installer and Setup Wizard. Give your setup program a name and press OK:

The Setup Wizard will then walk you through the remaining steps. First click next and then decide if you need a Windows or Web application. You probably don’t yet need any of the other special packages, so just click next. Even if you did, you can still add them at a later date:

Then select the files that will be coming out of your application. Select Primary for all your exes, dlls etc. You probably don’t need source code so leave this unchecked. Or debugging symbols. But you will probably need to include documentation files, if you have those. Click next:

Then use the next section to add any other files such as chm, pdf, rtf etc, and then select next:

After clicking finish you will see that a new project gets added to your application:

Editing your installer project

To edit your project properties to eg change its name, right click on the project and select properties:

There are three main folders in the user interface: Application Folder, User’s Desktop and Users Programs Menu. The Application Folder will specify where the software is located. For example, if you wish this to contain the executable of your application, then copy the exe file, right-click the Application Folder and paste the application to it. You can also right-click the executable file in order to create shortcuts, which can be inserted into the User’s Desktop / User’s Programs Menu. This enables the shortcut to be created on the user’s desktop and in the main Programs menu:

If you wish, you can make it look more organized by right-clicking the User’s Programs Menu in order to create a new folder with which to house your shortcut. You can also re-name and/or tidy up your shortcut, eg by giving it the same name as your main application:

Ditto the User’s Desktop folder:

To change the destination of the application folder right-click the Application Folder in the File System window and choose Properties:

DefaultLocation gives you the overall structure of the folder location. You might wish to remove the ‘Manufacturer’ section, for example, if you do not wish to include this in your overall folder location. You can also individually modify each of these, such as ‘ProgramFilesFolder’ if you prefer your programs to be installed elsewhere:

To change the default location of installed programs:

Click Start.
Click Run…
Type Regedit.
Look for this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ Windows\CurrentVersion

In the rightside window look for ProgramFilesDir. Double click on it and change C:\Program Files to another folder or directory:

Creating additional sub-folders

Right-click the Applications Folder and select Add -> New Folder. Rename and add any additional files as required. Once added, right-click on this folder to view its properties and make sure its AlwaysCreate property is set to true, to ensure this folder and its contents are created upon installation:

Setting the application icons
In the File System editor, go to where a shortcut is located (eg User’s Desktop / User’s Programs Menu), right click and choose its properties. In the properties, select the Icon field and in the drop down menu that appears, use the browse to identify the icon file that you want to use:

In the Icon dialog that appreas use the browse button to locate the icon file (*.ico) of your choice:

In this example for the User’s Desktop I selected ‘Add File…’ and used the icon I had developed for the ‘RouteOptimizer’ project I was working on, located in the ‘res’ folder of the said project:

Ditto User’s Programs Menu:

Building your installer project

By default when you build your project it will build your main application. Build it by right-cliking on the installer project and choosing Build:

Testing your installer package

Once this is done, locate your project in Visual Studio, go into the Debug folder and you will see two different installers used for two different purposes:

Test the installer by double-clicking one of them eg setup.exe and work through the setup wizard:

Click Next, changing any other properties as you see fit, the folder for example:

And after working through any other remaining sections of the wizard, that is pretty much it:

Look on the desktop and program menus to check that all of your program shortcuts, files, folders etc have been correctly installed.

Latest Comments

  1. KYAW ZAW TUN 18 March 2012
    • Andy 18 March 2012
  2. actual 12 May 2012
    • Andy 19 May 2012
  3. Peter 7 July 2012
    • Andy 7 July 2012
    • Tarun Kumar Singh 5 September 2012
  4. Sandiego 30 July 2012
    • Andy 30 July 2012
  5. faris 31 July 2012
    • Andy 31 July 2012
  6. Alex 21 August 2012
  7. alhmzawey 11 January 2013
    • Andy 11 January 2013
  8. chandan kumar sharma 14 January 2013
  9. Adriana 18 January 2013
  10. Daniel 23 January 2013
    • Andy 27 January 2013
  11. Naveen C 29 January 2013
  12. Sub Dee 14 March 2013
    • happyuk 14 March 2013
  13. Skip 31 March 2013
  14. sanaullah 4 April 2013
  15. Hassan 22 July 2014
  16. Randy Billingham 3 March 2015
  17. kasiim 16 August 2015
    • Andy 17 August 2015
  18. Bless Lemon 7 May 2016
  19. okoro 19 June 2016
  20. IshanthSriram 7 July 2017

Leave a Reply to chandan kumar sharma Cancel reply