【问题标题】:Wix: How to specify a pre-installation detectionWix:如何指定安装前检测
【发布时间】:2013-06-14 07:52:00
【问题描述】:

我正在阅读 wix 的教程和手册,并试图弄清楚如何应用预安装检测,例如检测机器上是否已安装 Visual Studio 2012 和 Update 2。

以下是wix源代码,但不确定注册表项是否是检测的先决条件。

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:dd="http://schemas.microsoft.com/wix/2005/01/dd">
<!-- Detection keys fragment. -->
<Fragment>
    <!-- TARGETDIR should be set by a type 51 CA to the root installation location for all products. -->
    <DirectoryRef Id="TARGETDIR">
        <!-- Use all variables in the full key path for the auto-generated GUID, 
             including LANG, since [ProductName] is lang-specific. 
        -->
        <Component Id="Detection_Keys_Reg" Guid="$(autoguid.ComponentGuid(Detection_Keys_Reg,$(var.ProductFamily),$(var.ProductEdition),$(var.VSRegVer),$(var.Lang)))">
            <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\$(var.VSRegVer)\Setup\[ProductName]">
                <RegistryValue Id="Detection_Keys_RegKey_1" Name="InstallSuccess" Type="integer" Value="1" KeyPath="yes" />
                <RegistryValue Id="Detection_Keys_RegKey_2" Name="SrcPath" Type="string" Value="[SourceDir]" />
            </RegistryKey>
        </Component>
    </DirectoryRef>
    <Feature Id="Detection_Keys" Absent="disallow" AllowAdvertise="no" Description="Used to detect product installation" Display="hidden" Level="1" InstallDefault="local" Title="Detection" TypicalDefault="install">
        <ComponentRef Id="Detection_Keys_Reg" />
        <dd:ExtensionData FeatureGuid="67DC7E25-1836-42AA-A0F8-6E85528D6986" InstallDirectory="TARGETDIR" AllowRunFromSource="no" FeatureGFN="DetectionKeys">Detection Keys</dd:ExtensionData>
    </Feature>
</Fragment>

文件夹中的两个注册表项

"HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\Setup\Microsoft Visual Studio Ultimate 2012\"

在我安装 VS2012 后确实存在(但不在 HKLM 中)。有些标签看不懂(还在看说明书)

所以问题是: 1.这是为了检测吗? 2. 需要的软件不存在时,如何写一些弹窗提示。

您能否为此提供一些典型示例?

谢谢!

【问题讨论】:

    标签: windows wix


    【解决方案1】:

    尝试在Product 元素中使用Condition 元素。引用条件元素的 WiX 文档:在 Fragment 或 Product 元素下,条件变为 LaunchCondition 条目。

    如果条件失败,安装将中止,并显示您希望它显示的消息。

    一个非常简单的例子:

      <Condition Message="Minimum 1 GB of RAM required. Aborting installation.">
        <![CDATA[Installed OR PhysicalMemory >= 1024]]>
      </Condition>
    

    如果您想使用注册表项,请使用 RegistrySearch 元素设置属性,如下所示:

      <Property Id="TEST">
        <RegistrySearch Id="TestRegKey"
                        Root="HKLM"
                        Key="Software\TestKey"
                        Name="Version"
                        Type="raw" />
      </Property>
    

    现在您可以在条件的内部文本中使用此属性。

    【讨论】:

    • 是的,这几乎是我想要的,但我不明白的一件事是,为什么我的问题中的示例代码被注释为关键检测?真的好像往注册表里写了一些信息。
    • 它似乎在设置一个注册表项。也许该组件的 Feature 元素中的某些属性做了一些事情,但我看不到任何明显的东西。您可以尝试阅读文档,看看是否有帮助..
    【解决方案2】:

    1.用于VS/更新检测的注册表键

    您可以使用以下注册表进行检测,其值为 UpdatedVersion= CurrentBuildNumber=11.0.60315 对于 VSUpdate2

    注册表项 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vs\Servicing\12.0\professional

    2.如果您的意图是搜索 VSUpdate2,您需要使用registrysearch 标签,它将为您搜索值。更新值后,您可以在托管 UX 中弹出自定义逻辑

    【讨论】:

    • 其实我的主要目的是编写代码来处理安装前检测的一般过程以及当一个条件为假时如何反应。之前看到过几个registrysearch标签,以后会多看的。
    • 这真的很有帮助。手动检查注册表项时,我不知道 32 位和 64 位机器之间的区别。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 2013-07-07
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多