Professional Documents
Culture Documents
Posted by VIJI Monday, March 1, 2010 Creating a Setup and Deployment Project In this article I will cover the basics of creating a Windows Installer. This article will explain the step by step process of creating a Setup Project.
Step 1: Create a Sample .Net Project. I have named this project as "TestBlogProject".
There are five different templates that are available when you select the project type 'Setup and Deployment Projects'.
1. Setup Project: Creates a Windows Installer project to which files can be added. This
project type is the most generic of the five.
2. Web Setup Project: Creates a Windows Installer web project to which files can be 3. 4. 5.
added. Merge Module Project: Creates a Windows Installer Merge Module project to which files can be added. This project type is most commonly used for using third party products. Setup Wizard: Creates a Windows Installer project with the aid of a wizard. Cab Project: Creates a Cab project to which files can be added.
For the purpose of this article, I will be using the template Setup Project. Provide a name for the project as well choose the location where this project will be established. (See Figure 3) Once you have done this click 'OK' and you should now see a screen like the following.
File System Editor The File System (Figure 6) provides you the essential tools to work with the application folder, user's desktop, and the user's programs menu.
The first thing we want to do here is to include the relevant files and folders we wish to install on the user's machine. This is accomplished by right clicking the Application Folder and selecting 'Add'. The following screenshot is an example of something similar you may see.
Now to add project output files to this folder, Click Project Output.
Click OK. Merely add one or more of the files that is vital for your application by clicking on File. Now that you have you files in place.
We could take additional steps such as manipulating the user's desktop with items such as a shortcut, as well you can add a program group to the user's program group. Create Shortcut
Name the shortcut as you want. I have given the name as TestBlog. Drag and drop to User's Desktop Folder
The next item you find of immense importance is the User Interface Editor. Inside of this editor you may eliminate or include dialogs that are needed for this install project. The following screenshot is the default User Interface that is created when I initially created this setup project (See Figure 10). The only variation is that I have added a Customer Information dialog.
To include the Customer Information dialog that I spoke of follow the following steps.
1. 2. 3. 4. 5. 6.
In Solution Explorer, select the deployment project and Right Click Click Properties. In the Property Pages dialog box, expand the Configuration Properties node, and then select the Build property page. Click the Prerequisites button. In the Prerequisites dialog box, make sure that the Create setup program to install prerequisite components box is checked. In the Choose which prerequisites to install list, check the prerequisites that you wish to install, and then click OK.
In Solution Explorer, select the deployment project, right click. Click Properties. In the Property Pages dialog box, expand the Configuration Properties node, and then select the Build property page. Click the Prerequisites button.
o o
If you want to deploy the installers for the prerequisites to a vendor, click Download prerequisites from the component vendor's web site. If you want to deploy the installers for the prerequisites to the same location as your application installer, click Download prerequisites from the same location as my application .
If you want to deploy the installers for the prerequisites to a different location, click Download prerequisites from the following location and enter a local path, URL, or file-share location.
Click OK to continue.
In this article, I have covered adding a new setup project, about File System Editor, adding installer prerequisites to Windows Installer.
Step 2 Design your own application. Here we have a simple login form for example.
Step 3 After completing the design and coding, build the solution of the project in release mode.
Step 4 Check the Release folder for the file ProjectName.exe. Here in this example we have the project name as sample so we can find a file with the name Sample.exe. Double click the executable file and check the example.
Step 5 Create a Deployment Project. Select the Other Project Types -> Setup and Deployment -> Setup project. Here we have the setup project for example as SampleSetup.
Step 6 Add the Sample.exe project application file inside the Application Folder.
Step 7 To make a shortcut for the project right click File System on Target Machine and create shortcut of the application. Here in this example the project shortcut is created in program files folder.
Step 10 Move the Shortcut file to specified target. Note if you need another shortcut for some other target also create use same steps.
Step 12 The setup file created in release folder of the project specified path.
Step 14 The SampleSetup project is extracted and shortcuts are created. Now run your application.
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 TargetMachineunder three folders Application Folder Users Desktop Users Program Menu
6.Select Application Folder and right click Add>Project Output>select Primary output
7. Select Users 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 users 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
11. Select the Release folder for build. (Select Properties in right click of Setup Project)
12. Set the Compression Mode Mode 1: Optimization for speed (Installation Speed) Mode 2: Optimization for size (Setup file size)
13. Once successfully build the setup. Please look up in inside Release folder
When you want to install the setup file or exe file 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. (Framework 4.0 need .NET Framework 4 Client Profile). #1 .NET Framework 2.0 Redistributable Package Downlaod #2 .NET Framework 4 Client Profile Downlaod
II. Create shortcut icon in Users Desktop, Users Programs Menu and Add/Remove Programs
Note: System support only .ico file format a. Users Desktop Step 1: Add an icon file (.ico) in project
Step4: Select Users Desktop or Users Program Menu and right click on right side pane
Step7: Here the sample product name is Your Product Name for demo purpose
Step 12: Add File button will be enable once you have clicked the Application Folder
b. Users Programs Menu Kindly follow the same steps for shortcut added in Users Program Menu. C. Add/Remove Programs Icon If you want to add your icon in Control Panel > Programs >Uninstall, You need to follow the below steps.
Step 1: Select the setup project in Solution Explorer and right click, select the properties
Add the icon from Application Folder. View Icons Install your setup in target machine, You can view the shortcuts in Desktop, Start Menu and Uninstall Programs. Figure 1: Shortcut icon in Desktop
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 vendors 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
Click Ok, prerequisites will associate based on your install location selection.
IV. Setup file User Interface customization
If you want to customize the installation process screens. Visual Studio provides facility through User Interface. Right click of setup project, Select View and Click User Interface.
Here, you can see the hierarchy tree of installation process screens. a. Add new dialog window Step 1: Right click desired selection, Select Add Dialog
b. Re-order the Screens Right click of desired screen which you need to move the specific place and select Move Up and Move Down
c. Change the text and banner images Right click and select the Properties Window where you need to edit the text and image.
Once youve complete the changes and Build the project again. Now, you setup file is professionally ready.
How do avoid multiple instance in installed application? In Program.cs file add the below code.
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Process[] process = Process.GetProcessesByName(Application.ProductName); //Prevent multiple instance if (process.Length > 1) { MessageBox.Show("{Application Name} is already running. This instance will now close.", "{Application Name}", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } else { Application.Run(new <Initial Form>()); } }