Visual Studio Setup project FAQ

http://social.msdn.microsoft.com/Forums/zh/winformssetup/thread/717cfce0-3061-400f-9ea3-069f73f3a473

1. Can I make a shortcut to uninstall my application when clicked?
Normally setup project doesn’t support that function and also Microsoft recommend users to 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;
            uninstallProcess.Start();
        }
    }
}
4). Now you can add UninstallApp console application to the setup project and create a shortcut for it. You can name the shortcut as “Uninstall”.

Related Topic
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/9a60c9ab-5d75-4d11-98e2-fd3b83f800ed/


2. Can I package .NET Framework along with my setup package into just one file?
Yes. In the prerequisites dialog, 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.

Related Topic
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/131cfa22-da2b-4114-a832-21dff63bd4d9


3. How can I add a dialog shows Checkboxes and install multi-application based on 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 .

In this document, it tells you how to install optional files, File A and File B based on user’s selection. You can use this way to deploy two applications or components.

Related Topic
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/63cbd3ee-6511-44e9-a964-9fa2de5c36fe/



4 . What is the difference between Setup.msi and Setup.exe?
Reply: These are the differences between them.
1) Click 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 the setup.exe. This means the program must be ran as 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 dialog 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 dialog. 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 msiexec command to install the setup.msi file. We can get details about the msiexec command from:http://msdn.microsoft.com/en-us/library/aa372024(VS.85).aspx .

These are two blogs about bootstrapper which can help you understand what bootstrapper is:
http://blogs.msdn.com/chrsmith/archive/2005/05/06/The-way-it-really-is.aspx
http://blogs.msdn.com/misampso/archive/2004/03/11/88402.aspx



5. How can I use CustomActionData to get user input from an installation interface in my custom action?
  Reply:  When we create a Setup Project to generate a setup package, we can add some dialogs in the User Interface view to customize the UI. We can also add some custom actions in the Custom Actions view to custom the setup process. In some cases, we need to pass some parameters those we get from the user input to the custom actions; we can use the CustomActionData property of the custom action to do this.

  The walkthrough below shows the detail steps:http://msdn.microsoft.com/en-us/library/9cdb5eda%28VS.71%29.aspx


http://social.msdn.microsoft.com/forums/en-US/winformssetup/thread/ba82242a-0dae-44ca-91a0-7127ea9f9f6b/


6. 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 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.
 
An MSDN article written by Michael Sanford, documents when to use each technology.

In the following article, it has the updated comparison table to account for newer features in Visual Studio 2010.
Related threads:

 
7. 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 setup project Version number and update AssemblyVersion and AssemblyFileVersion numbers (In Project->AssemblyInfo.cs file) of each project to higher numbers.

Related threads:
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/be85add9-6786-4144-bd9e-8d245bddc82a    

All Replies

  • Friday, September 03, 2010 1:42 AM
    Avatar of atrockz
    atrockz
    Avatar of atrockz
    atrockz
    10 Points 3 0 0
    Recent Achievements
    First Marked Answer First Forums Reply First Helpful Vote
    10 Points
     
     
    Hey thanks for the info.
    I am building a msi installer uinsg VS Setup project for windows 2008 R2, x64 platform. In my custom action i have a vbscript, in this vbscript i am trying to run a privilege command line command "bcdedit" but the operation fails. The command is "bcdedit -set testsigning on"
    I treid following methods
    1. WScript.Shell's run command but it returns error code 1, i.e. invalide function
    2. WScript.Shell's Exec function but when installer exectues this command its throws an error saying "There is a problem with windows installer package, A reqred script for installation could not be run"
    3. Making a batch file containg this bcdedit command and run that batch file from vbscript. The batch file get executed and the bcdedit command ouput shows "'bcdedit' is not recognized as an internal or external command,operable program or batch file." Looks like WScript.Shell only support command for old windows OS like xp and all only. 
    Can someone please let me know how do i run bcedit command in Windows 2008 R2.
    Thanks in advance. 

Comments