如何指定 Visual Studio 安装程序条件? [英] How do I specify Visual Studio Installer Conditions?

查看:23
本文介绍了如何指定 Visual Studio 安装程序条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Visual Studio 安装项目,我希望安装程序仅在我添加到项目 UI 的复选框 (A)"表单上的复选框被选中时才创建特定文件夹.复选框的属性名称是 CHECKBOXA1,但我不知道在文件夹的 Condition 属性中放置什么,以便只有在选中复选框时才会创建它.

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 'Condition' property for your folder, place the following:

复选框A1=1

这将确保仅在选中 CHECKBOXA1 后才安装该文件夹.

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

好的,我已经想出了如何做到这一点,但它有点搞砸了.关于 Visual Studio 安装程序的另一个奇怪的怪癖.

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.

假设选中CHECKBOXA1 后我们要安装的文件夹名为Folder1",我们将在Folder1 中放置一个名为test.txt 的示例文件.

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.

首先,我们需要创建一个在安装过程中永远不会显示的包含文件夹,但我们需要它来使其余部分工作.因此,在您的文件系统窗口中,创建一个文件夹(我称之为容器").Condition 属性应该设置为 CHEKCBOXA1=1,就像我们谈到的那样,并且 DefaultLocation 属性可以设置为您想要的任何位置,例如 [ProgramFilesFolder]\MyApplication.
现在是重要的部分.确保Container"文件夹的 DefaultLocation 属性未设置为 [ProgramFilesFolder]\MyApplication\Container,因为这将始终创建一个Container"文件夹,而不管 Condition 属性如何.好的,这会处理容器文件夹.如果这样做正确,当您安装应用程序时,您将永远不会看到 Container 文件夹.

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.

现在,在文件系统"窗口的容器文件夹中,创建您想要的实际文件夹,在本例中为 Folder1.将其 Condition 属性设置为 CHECKBOXA1=1,并确保其中的任何内容的 Condition 属性也设置为 CHECKBOXA1=1.

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.

现在运行安装时,文件夹1将仅出现CheckBoxa1,仅在选中CheckBoxa1.

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

我不明白为什么需要 Container 文件夹才能正常运行,但它可以工作,所以我使用它.

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

这篇关于如何指定 Visual Studio 安装程序条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆