简体   繁体   中英

Wix: How to specify a pre-installation detection

I'm reading wix's tutorial and manuals, and trying to figure out how to apply a pre-installation detection, say detecting if Visual Studio 2012 and Update 2 has been installed on the machine.

the following is a wix source code, but I'm not sure whether the registry keys are prerequisite for detection.

<?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>

The two registry keys in folder

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

do exist (but not in HKLM) after my installing VS2012. I don't understand some of the tags (still reading the manual)

so the questions are: 1. Is this for detection? 2. How do I write some pop up messages when the required software does not exist.

Can you provide some typical samples for this purpose?

Thanks!

1.Registry key to use for VS/Update Detection

You can use below registry for detection purpose, This has value UpdatedVersion= CurrentBuildNumber=11.0.60315 For VSUpdate2

Registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\DevDiv\\vs\\Servicing\\12.0\\professional

2.If your intention is to search for VSUpdate2 you need to use registrysearch Tag, Which will search the value for you. Once you have updated value you can have logic of custom pop up in your Managed UX

Try using a Condition element within your Product element. Quoting from the WiX documentation of the condition element: Under a Fragment or Product element, the condition becomes a LaunchCondition entry.

In case the condition fails, the installation will abort, showing the message you want it to show.

A very simple example:

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

In case you want to use a registry key, set a property using the RegistrySearch element as in:

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

Now you can use this property within the inner text of the Condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM