Visual Studio: conditionally create shortcuts in an installation project?

I am working on an installation project in Visual Studio, and I would like the user to be able to specify whether to create a desktop shortcut and / or a Start menu shortcut in the program using checkboxes.

I can install the installer to create work shortcuts in the appropriate places, and I added a dialog box containing checkboxes for the installer; however, I cannot create (or lack thereof) these shortcuts related to the status of these flags.

I assume that I need to set the Condition property, but I'm not sure about the specific syntax. Is this possible, and if so, how can I do this?

+6
visual-studio-2008 windows-installer setup-project
source share
2 answers

It's impossible.

Check here the Microsoft Forum for a response from Microsoft in April this year covering the same issue as yours.

+3
source share

A related feedback element said:

In the event that you want the flag to control only the installation of the shortcut, and not its purpose, there is currently no solution in the Visual Studio setup projects , and this is best done either using additional MSI and a post-build script to manually change the MSI after each build or by switching to a more advanced (and flexible) development tool (for example, Windows Installer XML).

You cannot do this in the point-and-click interface of VS, but it is actually not difficult to do what you want with a simple user action.

alt text

Define a script in VBScript or JavaScript. You can configure an arbitrary action to run based on any condition, including a check box in the dialog box.

alt text

Inside the script, you parse the input and create a shortcut. I used the convention to split args into a script with | character, so here is how I make out:

var parameters = Session.Property("CustomActionData").split("|"); var targetDir = parameters[0]; var checkBoxState = parameters[1]; 
+6
source share

All Articles