Sunteți pe pagina 1din 33

Create Setup and Deployment Project Visual Studio 2008

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".

Figure 1 Sample Project

Create a Setup Project Open the TestBlogProject in the VS IDE.

Figure 2: Add New Project

Figure 3: Setup Project Dialog

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.

Figure 4: Default Setup Project File View

Now that we have an empty Setup Project established.

Let us discuss about the various editors that are available.

1. Right Click on the Setup Project and Click View.

Figure 5: File System Editor

1. Click on the File System

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.

Figure 6: File System Editor

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.

Figure 7: Add Project Output

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.

Figure 8: Project Output

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

Figure 9: Desktop Shortcut to application

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.

Figure 10: User Interface Editor

To include the Customer Information dialog that I spoke of follow the following steps.

1. Under Install right click on the 'Start' node

2. Choose 'Add Dialog'

Figure 11: Customer Information

1. Select the Customer Information Dialog and click 'OK'


As you can see there are is an ample variety of dialogs you can choose from.

Prerequisites Installation in Windows Installer


Most applications have prerequisites: Components such as the .NET Framework runtime must be available on a target computer in order for the application to run. The deployment tools in Visual Studio include the capability to automatically detect the existence of components during installation and install a predetermined set of prerequisites a process known as bootstrapping.

This will be achieved as follows:

To choose which prerequisites to install

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.

To specify the download location for prerequisites

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.

In the Prerequisites dialog box, choose a location:

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.

Steps to Create Setup and Deployment Project in Dot Net VS 2008


Posted by praveen on July 10th, 2009 | 78 Comments Step 1 Create your own windows application. Create a new Windows application project in C# and named it as Sample.

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 8 Create the shortcut of the application.

Step 9 Rename the shortcut of the application.

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 11 Now build the solution in release mode.

Step 12 The setup file created in release folder of the project specified path.

Step 13 Run the setup, step the path to extract.

Step 14 The SampleSetup project is extracted and shortcuts are created. Now run your application.

Create an EXE or Setup File in .NET Windows Application


Hi .NET Architects! 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 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

Step2: Select the icon file

Stpe3: Icon file added in Application Folder

Step4: Select Users Desktop or Users Program Menu and right click on right side pane

Step5: Add primary output of actual application and click OK to select

Step6: Rename the actual name to your desired project/product name

Step7: Here the sample product name is Your Product Name for demo purpose

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

Step 9: Select Icon, next Browse icon file

Step10: Browse icon file in Application Folder

Step 11: Click Application Folder

Step 12: Add File button will be enable once you have clicked the Application Folder

Step 13: Select your product icon and Click OK

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

Figure 2: Shortcut icon in Users Program Menu

Figure 3: Shortcut icon in Uninstall Programs

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 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

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.
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

Step 2: Select the dialog which you wish to add

Step 3: New dialog added

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.

V. Prevent Multiple Instance Running.

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>()); } }

Help me to improve better by sharing your feedback here. Thanks!

S-ar putea să vă placă și