Create an EXE or Setup File in .NET Windows Application

Visual Studio Setup and deployment Projects provides to make an executable or installer file in .NET windows application is easy and rapidly.
Visual Studio provides templates for four types of deployment projects: Merge Module Project, Setup Project, Web Setup Project, and Cab Project. In addition, a Setup wizard is provided to help step you through the process of creating deployment projects. You can see the templates and the wizard in the New Project dialog box under the Setup and Deployment Projects node.
The following are guidelines for choosing the right type of deployment project for your project.
1)Merge Module Project : Packages components that might be shared by multiple applications.
2)Setup Project : Builds an installer for a Windows-based application.
3)Web Setup Project : Builds an installer for a Web application.
4)Cab Project : Creates a cabinet file for downloading to a legacy Web browser.
5)Smart Device Cab Project : Creates a Cab project to deploy device applications.
This topic demonstrates deployment using a Setup and Deployment Project.
Setup Projects
Setup projects allow you to create installers in order to distribute an application. The resulting Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation. When the .msi file is distributed and run on another computer, you can be assured that everything necessary for installation is included; if for any reason the installation fails (for example, the target computer does not have the required operating system version), the installation will be rolled back and the computer returned to its pre installation state.

I. Create Setup Project

The following steps will gives the elegant guidance to create an executable or installer file.
1. Go to file menu > click Add > new project >now “Add New Project” dialog will appear.

2. Select the “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project” give name project name in name text box finally click OK.

3. New project appear in solution explorer,for eg., you have give the name “MyEXE” file will be displays with given name.

4.Right click the MyEXE > go View > click “File System”

5.You can see the “File System on TargetMachine”under  three folders
Application Folder
User’s Desktop
User’s Program Menu

6.Select Application Folder and right click Add>Project Output>select Primary output

7. Select User’s Desktop right click on the right side pane>click create new shortcut>select output file from Application folder>change the file name from  primary output name to MyEXE

next >>

Same procedure follows the user’s program menu also
8.If you want to change the Manufactures name, just right click the project go to properties

change the properties as per you requirement
9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)

EXE or installer will be available on his physical path…

When you want to install  the EXE on the client machine, before you should be installed .NET Framework on that machine because, Applications and controls written for the .NET Framework v2.0 requires the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs.
you can get it from here

II. Create shortcut icon  in User’s Desktop and User’s Program Menu

Step1: Select ‘User’s Desktop’ or ‘User’s Program Menu’  and right click on right side pane
Create short cut on user's desktop
Step 2: Add primary output of actual application and click ‘OK’ to select

Step 3: Rename the actual name to your desired project/product name

Step 4: Here the sample product name is ‘Your Product Name’ for demo purpose

Step 5: If we want to add icon on shortcut, Click Properties Window

Step 6: Select Icon, next Browse icon file

Step 7:  Browse Icon File (Format should be .ico, other formats are not acceptable)

Step 8: Click  ‘Application Folder’

Step 9: Add File button will enable once you have clicked Application Folder

Step 10: Select your product icon from somewhere in system and Click ‘OK’
User should follow the same steps for shortcut added to User’s Program Menu.
Install your setup in target machine, You can view the shortcuts in Desktop and Start Menu.
Figure: Shortcut icon in Desktop

Figure: Shortcut icon in User’s Program Menu

III. Add Prerequisites

Prerequisites are provide support resources to run the installed process on your target machine.
Visual Setup and Deployment projects are automatically detect the required prerequisites need to install the system. But the question is what is the source for install the prerequisites?  No need to worry, Visual Studio IDE provides three options to install the prerequisites on your system.
  • Download prerequisites from component vendor’s website (default option)
  • Download prerequisites from the same location as my application
  • Download prerequisites from the following location
How to add prerequisites in Visual Studio?
1. Select Project in Solution Explorer, Right click

2. Click the Prerequisites button in Property Pages

3. Select the required prerequisites from the window

Click ‘Ok’, prerequisites will associate based on your install location selection.

0 comments:

Post a Comment