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 project UI is checked. The name of the property for the checkbox is CHECKBOXA1 but I have no idea what to put in the Condition property of the folder so that it only gets created if the checkbox is checked.
In the Windows Start menu, you can search for "installer", and then select Visual Studio Installer from the results. If you have Visual Studio open, select Tools > Get Tools and Features..., which opens the Visual Studio Installer.
If you've already installed it and want to change the location, you must uninstall Visual Studio and then reinstall it. In the Shared components, tools, and SDKs section, select the folder where you want to store the files that are shared by side-by-side Visual Studio installations.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With