Creating a Setup File For Desktop Application Using Visual Studio 2010

Software used:

Procedure to create Setup file:
  1. Open an existing Windows form project solution to create a setup file.

  2. Right click on solution and in context menu click Add, then New Project. After that you can see a new project window, in that right side you can select Other Project Types in installed Templates, then select as shown below.

    setup

  3. Now you can see one project in the same solution as setup1. You can see the properties for this project and can change these properties as you wish like Author, Manufacture, etc. as in the following figure:

    file system

  4. Now the real part begins, here I am going to show you how you can import your project files to setup file, for that right click on this setup1 project and in context menu select Add, then click Project Output. After that you can see a pop up, from this pop up select required items, mainly Primary output and Localized resources (marked in red square which I have selected).

    output

    After adding these items as in above figure you will get the screen as below,

    items

    • Here you can see there are three folders on the left side tab called File System,
     
    Application Folder

    This is your Destination folder where you're going to install or copy the entire application, so here you can add all your project files

    User’s Desktop

    This folder is your desktop, here you can put shortcut of application file.

    User’s Programs Menu
    :

    This folder is your start menu context folder, here also you can put shortcut of application file, help file or any documents, etc.

    • Here on right side under Setup1 project tree and in inside application folder you can see item name starts with Primary output from <ProjName>, it is the output of your project i.e., it is going to be your main .exe file

    • And you can also see all your external .dll files required for your project to run.

  5. Now let’s see how to add extra files and folders in these three right side folders,

    Firstly, let’s see in Application Folder as shown below. Right click on this folder and in context menu select Add, then click File (What do you want)

    add

    • Here, I am going to add two files i.e., one Icon file and Database file, here you can also add documents and whatever you want.

     After adding files to Application Folder

    folder

    • Next we can add shortcut of application file to User’s Desktop, for this select User’s Desktop folder . On the right side you can see blank space having heading Name and Type. In that you can right click and then in context menu select Create New Shortcut as shown below.

    shortcut

    • Then you will get one pop up box like below, in that select Primary output From <ProjName>, then click OK.

    desktop

    • Now you can see one shortcut file added on that blank space, here you can change the name of shortcut and can give icon for this shortcut as in the following figure:

    folder

    • Next you can add shortcut file to the User’s Program Menu folder as I did in User’s Desktop folder and if you want you can add some document as well in this folder. This folder will come under your Start menu ->All programs folder, so if you want more files to be added then first add one folder into this User’s Programs Menu folder as shown below, then add whatever files you want.

    add

  6. Now let’s see how you can manage prerequisites, which is required. Run your application like .NET framework 3.0 or 4.0, VS report viewer and other prerequisites, for this right click on setup1 in Solution Explorer and select Properties. After that you can see one pop up there you can select prerequisites button then select what all prerequisites needed for your application to run Select any of the 3 radio buttons (select 1st one Default).

    properties

  7. Now you can design your setup.exe file as in the following figure:

    exe

    a. You can give banner image
    b. You can change Copyright Warning message, welcome text, etc.

  8. Now the time to build setup file, for this right click on Setup1 in Solution Explorer and select Build, That’s it.

    build

    After build success you can see in your project folder one extra folder created. Inside Debug folder you can see your setup file as shown below.

    ini
Note:
  • .msi extension file is the real setup file.
  • .exe file calls this .msi file to execute, without .exe file you can run .msi file but not .exe file.
Read more articles on Visual Studio: