WiX - 将字符串与 <?if ?> <? 中的 <property> 进行比较否则?>声明
WiX - compare String with <property> in <?if ?> <? else ?> statement
大家好,希望有人能帮我解决这个问题。我正在尝试将 属性 的值与手动定义的字符串进行比较。
我不确定它是否应该像这样工作这是我的代码。
<Variable Name="VS2013Installed" />
<Variable Name="VS2015Installed" />
<!-- Should Search the Registry for the Keys -->
<!-- Searches for the Key of Visual Studio 2013 -->
<Property Id="VS2013" Secure="yes" >
<RegistrySearch Id="SEARCH_VS2010" Type="raw" Root="HKCR" Key="VisualStudio.accessor.12.0\shell\Open\ddeexec\Application" >
</RegistrySearch>
</Property>
<!-- Searches for the Key of Visual Studio 2015 -->
<Property Id="VS2015" Secure="yes" >
<RegistrySearch Id="SEARCH_VS2015" Type="raw" Root="HKCR" Key="VisualStudio.accessor.14.0\shell\Open\ddeexec\Application" >
</RegistrySearch>
</Property>
<!-- Should compare the value of the property with the String-->
<?if [VS2013] = "VisualStudio.12.0" ?>
<?define VS2013Installed= "1" ?>
<?else ?>
<?define VS2013Installed= "0" ?>
<?endif?>
<!-- Should compare the value of the property with the String-->
<?if [VS2015] = "VisualStudio.14.0" ?>
<?define VS2015Installed= "1" ?>
<?else ?>
<?define VS2015Installed= "0" ?>
<?endif?>
<!-- This Condition is only here to get an Message Window with the values of the variables-->
<Condition Message="$(var.VS2013Installed)$(var.VS2015Installed)">
<![CDATA[0 = 1 ]]>
</Condition>
作为我得到的条件的结果:0,0
WiX 条件编译用于 WiX 变量。您需要 Windows 安装程序属性的条件。看起来您掌握了设置属性和使用 属性 表达式的方法;只需使其具有所有属性和条件即可。 (不过,您可以使用 WiX define
和 var
。)
您正在使用 WiX 工具集构建 Windows 安装程序包(.msi 文件)。 Windows 安装程序包是一个关系数据库,您可以使用 InstEd 等工具直观地看到这一点。 Windows 安装程序引擎 (msiexec) 使用数据库对产品执行标准和自定义操作(安装、修复、卸载等)。操作可以通过 Windows 安装程序属性设置、传递和检索数据。 属性 通常通过方括号中的名称引用,例如 [VS2015]
。除了 WiX 提供的自定义操作(您可能会或可能不会使用它们),安装时发生的一切都是 Windows 安装程序。
WiX 变量只是一种避免在 WiX 源中重复的方法。当 WiX 构建包时,它们是 "compiled away"。因此,它们的值是固定的。 WiX 的条件编译(定义、if 等)也在构建时被编译掉。
在您的代码中,您似乎希望在条件编译语句中使用 属性 值。 属性 直到 msiexec 运行才设置值。因此,您找到了另一种使用通过注册表搜索收集的信息的方法。一种方法可能是,如果您有一个支持 VS2015 的功能和另一个支持 2013 的功能,则根据引用 属性 值的表达式启用或禁用功能。
如果您想检测安装了哪些 Visual Studio 版本,请查看 WiX 提供的 WixVSExtension 并使用它提供的属性。
http://wixtoolset.org/documentation/manual/v3/customactions/wixvsextension.html
它确实包括 VS 2013 和 2015。
大家好,希望有人能帮我解决这个问题。我正在尝试将 属性 的值与手动定义的字符串进行比较。 我不确定它是否应该像这样工作这是我的代码。
<Variable Name="VS2013Installed" />
<Variable Name="VS2015Installed" />
<!-- Should Search the Registry for the Keys -->
<!-- Searches for the Key of Visual Studio 2013 -->
<Property Id="VS2013" Secure="yes" >
<RegistrySearch Id="SEARCH_VS2010" Type="raw" Root="HKCR" Key="VisualStudio.accessor.12.0\shell\Open\ddeexec\Application" >
</RegistrySearch>
</Property>
<!-- Searches for the Key of Visual Studio 2015 -->
<Property Id="VS2015" Secure="yes" >
<RegistrySearch Id="SEARCH_VS2015" Type="raw" Root="HKCR" Key="VisualStudio.accessor.14.0\shell\Open\ddeexec\Application" >
</RegistrySearch>
</Property>
<!-- Should compare the value of the property with the String-->
<?if [VS2013] = "VisualStudio.12.0" ?>
<?define VS2013Installed= "1" ?>
<?else ?>
<?define VS2013Installed= "0" ?>
<?endif?>
<!-- Should compare the value of the property with the String-->
<?if [VS2015] = "VisualStudio.14.0" ?>
<?define VS2015Installed= "1" ?>
<?else ?>
<?define VS2015Installed= "0" ?>
<?endif?>
<!-- This Condition is only here to get an Message Window with the values of the variables-->
<Condition Message="$(var.VS2013Installed)$(var.VS2015Installed)">
<![CDATA[0 = 1 ]]>
</Condition>
作为我得到的条件的结果:0,0
WiX 条件编译用于 WiX 变量。您需要 Windows 安装程序属性的条件。看起来您掌握了设置属性和使用 属性 表达式的方法;只需使其具有所有属性和条件即可。 (不过,您可以使用 WiX define
和 var
。)
您正在使用 WiX 工具集构建 Windows 安装程序包(.msi 文件)。 Windows 安装程序包是一个关系数据库,您可以使用 InstEd 等工具直观地看到这一点。 Windows 安装程序引擎 (msiexec) 使用数据库对产品执行标准和自定义操作(安装、修复、卸载等)。操作可以通过 Windows 安装程序属性设置、传递和检索数据。 属性 通常通过方括号中的名称引用,例如 [VS2015]
。除了 WiX 提供的自定义操作(您可能会或可能不会使用它们),安装时发生的一切都是 Windows 安装程序。
WiX 变量只是一种避免在 WiX 源中重复的方法。当 WiX 构建包时,它们是 "compiled away"。因此,它们的值是固定的。 WiX 的条件编译(定义、if 等)也在构建时被编译掉。
在您的代码中,您似乎希望在条件编译语句中使用 属性 值。 属性 直到 msiexec 运行才设置值。因此,您找到了另一种使用通过注册表搜索收集的信息的方法。一种方法可能是,如果您有一个支持 VS2015 的功能和另一个支持 2013 的功能,则根据引用 属性 值的表达式启用或禁用功能。
如果您想检测安装了哪些 Visual Studio 版本,请查看 WiX 提供的 WixVSExtension 并使用它提供的属性。
http://wixtoolset.org/documentation/manual/v3/customactions/wixvsextension.html
它确实包括 VS 2013 和 2015。