Visual Studio Setup project FAQ

Can I make a shortcut to uninstall my application when clicked?

Normally setup project doesn’t support that function and also Microsoft recommends users uninstall applications via Control Panel. But you can use the following way to make an uninstall program along with your application.
1) Provide now you have an application and a setup project, you can create another application called UninstallApp. That application can be a simple console application.
2) To uninstall an application, you need to run “MsiExec.exe /I {productcode} ” in the command line. That can bring out an uninstall wizard to move on to the next.
3) For example now you have an application whose product code is “09411687-F56E-4480-906A-F0186A9FF6CE”, so the UninstallApp can be coded like this.
namespace UninstallAPP.
    class Program
        static void Main(string[] args)
            Process uninstallProcess = new Process();
            uninstallProcess.StartInfo.FileName = “MsiExec.exe”;
            uninstallProcess.StartInfo.Arguments = “/I{09411687-F56E-4480-906A-F0186A9FF6CE}”;
            uninstallProcess.StartInfo.UseShellExecute = false;
4) Now you can add the UninstallApp console application to the setup project and create a shortcut for it. You can name the shortcut “Uninstall”.

Can I package .NET Framework along with my setup package into just one file?

Yes. In the prerequisites dialogue, you can select “Download prerequisites from the same location as my application” and build your package. Visual Studio will copy all the bootstrapper packages into the same folder as setup.exe and MSI. Then you can use some tools to package all the files into a self-extract package.

How can I add a dialogue that shows Checkboxes and install multi-application based on the user’s selection?

You can add “Checkboxes User Interface Dialog Box” into your setup project. Here is the document talking about this Checkboxes User Interface Dialog Box.
This document, tells you how to install optional files, File A and File B based on the user’s selection. You can use this way to deploy two applications or components.

What is the difference between Setup.msi and Setup.exe?

These are the differences between them. 1) Click the setup.exe file to install.      Setup.exe is a setup bootstrapper file. It is built by MSBuild taking in a list of custom packages defined in XML files.  Setup.exe program will then detect if the custom package is installed and download and install it if necessary. When we click it, it will read the Setup.ini to determine the required installation and start installing.
If the setup.exe is generated in visual studio 2005, the user must have the administrator privilege to execute it. We can see a shield on the icon of setup.exe. This means the program must be run by an administrator.
If the setup.exe is generated in visual studio 2008, the user does not need to have the administrator privilege to execute it, the UAC dialogue will show only when some operations need administrator privilege to execute. We will not see a shield on the icon of the setup.exe.
2) Click setup.msi to install.
     Setup.msi is a Windows Installer package. Unlike the Setup.exe, the MSI packages do not chain-install any prerequisites or other custom packages; it only installs the main application itself. We can change its name to something more conventional by modifying the Output file name property in the setup project’s Property Pages dialogue. When we click it, the setup.msi file will be opened by the Windows Installer program, so we need to install the Windows Installer of the correct version to run the setup.msi. We can also use the MSI exec command to install the setup.msi file. We can get details about the MSI exec command from:

How can I use CustomActionData to get user input from an installation interface in my custom action?

When we create a Setup Project to generate a setup package, we can add some dialogues in the UserInterface view to customize the UI. We can also add some custom actions in the CustomActions view to custom the setup process. In some cases, we need to pass some parameters that we get from the user input to the custom actions; we can use the CustomActionData property of the custom action to do this.

Which deployment should I choose? ClickOnce or MSI?

Visual Studio provides two different strategies for deploying Windows-based applications: ClickOnce technology and Windows Installer technology. ClickOnce deployment greatly simplifies the process of installing and updating an application, but ClickOnce doesn’t meet sophisticated configuration requirements; it can only install applications on a per-user basis. Windows Installer is able to handle any deployment challenge, it can install applications on both a per-user and per-machine basis, but it doesn’t offer auto-update and other capabilities which are available in ClickOnce. Choosing between ClickOnce and Windows Installer is based on your requirement.

How can I install a new version without manually uninstalling the current one with MSI?

This can be done by setting the RemovePreviousVersions property of the setup project to true. With this property set, the old version will be automatically uninstalled during the installation of the new version. Notice you also need to raise the setup project Version number and update AssemblyVersion and AssemblyFileVersion numbers (In Project->AssemblyInfo.cs file) of each project to higher numbers.