Click here to Skip to main content
15,920,636 members
Articles / Operating Systems / Windows

Visual Studio Windows Application Setup Project

Rate me:
Please Sign up or sign in to vote.
4.73/5 (88 votes)
29 Dec 2005CPOL5 min read 1.8M   9.6K   167   378
This article shows how to create and use the Windows Application Setup Project.

Image 1


I noticed that there are several articles on using Web Setup projects, but no articles could be found for Windows Setup projects. So I decided to share what I know about the VS Windows Setup Projects. I will be using the RunOnlyOnceCS.exe demo app I created for another CodeProject article, as the application we are creating the setup for.


Sooner or later, you need to create a setup project for an application. Personally, I am not a big fan of this type of distribution for an application. Still it has its uses. Using a setup project can be a good solution for a Windows application that has many dependencies on other assemblies / DLLs. The setup will figure out what the dependencies are for the application and automatically include them.

Note: This does not include the .NET framework.

Creating a Setup Project

This article is going to rely on screen prints since there really isn’t any code for this. The output will be a *.msi file that will install the application file(s), and add a shortcut to the desktop and to the Programs menu.

Note: if the user does not have admin rights to their box, they will not be able to run the MSI script or install new applications on their box.

Image 2

After you have created a new setup project, the first thing you will want to do is change the ProductName property on the setup project to match the application you are creating the setup for. I would also suggest changing the RemovePreviousVersion property to true. This is helpful when you want to release your next version of your app through this setup project.

Image 3

Next, click on the "Application folder", then right click, and click on Add/File. At this point, you will be able to add the Exe you are trying to create the setup for.

Note: if you make changes to the Exe, you will need to re-compile the setup project as well. It might be a good choice to add a setup project to your Windows project solution. Then you can choose the project output option instead of the file.

Note: if you know what a merge module is and want to add one to the setup project, you need to right click on the setup project and click Add Merge Module.

Note: you must also add any config or icon files you may need for this solution, here:

Image 4

Next, I always set the Always Create for the Program Directory to true. This is done by clicking on the "Application Folder" and then going to the properties.

Note: the DefaultLocation property will always be: [ProgramFilesFolder] [Manufacturer]\[ProductName]. If you want it to be something else, this is where to change it. Notice that the solution explorer has recognized the dependency or need for the .NET Framework for this app to run.

Note: this does not mean that the setup will install the .NET re-distributable framework. That is its own setup. The setup file is around 24 MB in size and can be downloaded from here.

Note: the setup can not install a .NET application without the .NET Framework already installed.

Image 5

Next, we want to create a shortcut to our application on the desktop. First, click on the "User's desktop" folder. Then right click and click on "Create New Shortcut".

Image 6

Next, you will see a dialog box to choose the application you want to create a shortcut to. Go to "Application folder" and add the exe you added in the previous step.

Image 7

If you click on the "User's desktop" and go to the Properties window, you will see some options. Something I normally add to the shortcut is a check to see if it already exists. This is an example of what little coding you can do in a setup project. I have turned on AlwaysCreate on the shortcut property. In doing this, I need to have a condition or I will multiply my desktop shortcuts with every new release. So I set the Transitive property to True and I set the condition to FILEEXISTS1<>"Shortcut to RunOnceOnlyCS.exe", where what is in the "" needs to match the name of the shortcut.

Image 8

Note: if you want your shortcut to have your application's icon, you need to add your icon file to the "Application folder". Next, click on the shortcut you just created in your "User's desktop". There is an icon property. Click the down arrow to get the dialog box. Navigate to the "Application folder" and select the icon file you just added.

Next, if you want to create a shortcut in the Start/All Programs menu, it is very similar to creating a shortcut on the "User's desktop". First, click on the "User's programs menu", then right click and add a folder. Name the folder the same as whatever your company or manufacturer name would be. Then, click on that newly created folder and add a shortcut just like we did in the step above.

Image 9

Finally, when you need to create a new setup for the next release of your application, you need to go to the setup project properties and change the version before you re-compile the setup project.

Image 10

Once you click off the version property, you will get a prompt to update the GUID for the ProductCode.

Note: if you do not click the Yes button in the dialog, you must manually get a new GUID for the ProductCode for the setup to properly remove the old program and install the new program.

Image 11

Note Do Not: change the UpgradeCode GUID. If you do, the user will have to uninstall the old program manually before the new version can be installed.

One last note

One thing that is really nice about the Setup Project is that it automatically adds your Windows application you are trying to install to Add/Remove Programs. So once this has been installed, you can go to Add/Remove Programs and remove the app, and it will clean up all the files and folders that were created. I guess this is in part why you might be using a setup project in the first place.


I hope this article has given you a taste of how to use the VS Setup Project. It is not the perfect solution for distributing Windows applications, but it is useful in certain situations where this solution fits the need.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior)
United States United States
I started my programmer career over 26 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out in 2004. I achieved my in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between and C# to be mostly syntax. In my current position I am programming in C# working on WPF and MSSql database stuff. Lately I have been using VS2019.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

Comments and Discussions

GeneralThanks. Pin
Gfw16-Jan-06 1:47
Gfw16-Jan-06 1:47 
GeneralRe: Thanks. Pin
kubben16-Jan-06 2:49
kubben16-Jan-06 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.