How do I specify Visual Studio Installer Conditions?

前端 未结 1 1113
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 10:25

I have a Visual Studio Installation Project and I want the Installer to create a specific folder only if a check box on a \'Checkboxes (A)\' form that I\'ve added to the pro

相关标签:
1条回答
  • 2020-12-29 10:34

    In the 'Condition' property for your folder, place the following:

    CHECKBOXA1=1

    This will make sure that the folder is only installed if CHECKBOXA1 has been checked.

    EDIT: OK, I've figured out how to do this, but it's kind of messed up. Another one of those strange quirks about the Visual Studio Installer.

    Let's assume that the folder we want to install if CHECKBOXA1 is checked is called 'Folder1', and we'll put a sample file in Folder1 called test.txt.

    First, we need to create a containing folder that will never show up during the install, but we need it for the rest of this to work. So in your File System window, create a folder (I called mine 'Container'). The Condition property should be set to CHEKCBOXA1=1 like we talked about, and the DefaultLocation property can be set to wherever you want, for example [ProgramFilesFolder]\MyApplication.
    Now here's the important part. Make sure the DefaultLocation property for the 'Container' folder is NOT set to [ProgramFilesFolder]\MyApplication\Container, as that will ALWAYS create a 'Container' folder, regardless of the Condition property. OK, that takes care of the container folder. If this is done properly, when you install your application, you will never see the Container folder.

    Now, inside the Container folder in the File System window, create the actual folder you want, Folder1 in this example. Set its Condition property to CHECKBOXA1=1, and also make sure that any content in it has its Condition property also set to CHECKBOXA1=1.

    Now when you run your installation, Folder1 will only appear if CHECKBOXA1 is checked.

    I don't understand why the Container folder is needed for this to function properly, but it works, so I use it.

    0 讨论(0)
提交回复
热议问题