Visual Studio: Conditionally Create Shortcuts in Setup Project?
I am working on a Setup 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 to the program by using checkbox开发者_开发问答es.
I am able to have the installer to create working shortcuts in the appropriate locations, and I added a dialog containing checkboxes to the installer; however, I am unable to have the creation (or lack thereof) of these shortcuts connected to the status of these checkboxes.
I'm assuming that I need to set "Condition" properties, but I'm not sure of the specific syntax. Is this possible, and if so, how would I go about accomplishing this?
The linked feedback item said:
In the case that you want the checkbox to only control whether the shortcut installs, and not its target, there is currently no solution in Visual Studio setup projects, and this is best accomplished either through extra MSI knowledge and a post-build script to manually modify your MSI after each build, or by migrating to a more advanced (and flexible) tool for setup development (for example, Windows Installer XML).
You can't do it within the VS point-and-click interface, but it's actually not difficult to do what you want with a simple custom action.
Define a script, in VBScript or JavaScript. You can set the custom action to run based on any condition, including a checkbox in a dialog.
Inside the script, you parse the input, and create the shortcut. I used the convention to separate args to the script with a | character, so this is how I parse:
var parameters = Session.Property("CustomActionData").split("|");
var targetDir = parameters[0];
var checkBoxState = parameters[1];
This is not possible.
Look here Microsoft Forum for a reply from Microsoft in April of this year covering the same problem as yours.
精彩评论