WiX检测.Net 4.0.3

Sea*_*rey 5 wix wix3.7

我有一个需要.Net 4.0.3(链接)的应用程序.

我发现这篇文章告诉我在哪里可以找到安装的.Net版本,但我能找到的是WiX编译器识别的包含属性列表(这里).

我已经尝试按照本文中的说明操作,它告诉我使用以下代码,但这只是在没有更新的情况下安装.Net 4:

<PropertyRef Id="NETFRAMEWORK40FULL"/>

<Condition Message="This application requires .NET Framework 4.0.3. Please install the .NET Framework then run this installer again.">
    <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
Run Code Online (Sandbox Code Playgroud)

如何通过预先定义的WiX属性或自行检查注册表值,如何进行特定4.0.3更新的WiX检查?

Sea*_*rey 4

经过一番阅读后,我最终在我的解决方案中添加了一个捆绑项目,该项目Product在标准 WiX 安装程序项目 ( MyProject.Installer) 中引用了我的 main 项目。然后我使用 aRegistrySearch来查找完整的 .Net 4 安装的版本。

<Bundle ....>
    <Chain>
        <PackageGroupRef Id="Netfx4Full" />
        <PackageGroupRef Id="Netfx403Update" />
        <MsiPackage Id="MyMsi" SourceFile="$(var.MyProject.Installer.TargetPath)" Compressed="yes" DisplayInternalUI="yes" />
    </Chain>
</Bundle>
<Fragment>
    <util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
                     Value="Version"
                     Variable="Netfx4FullVersion" />
    <util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
                     Value="Version"
                     Variable="Netfx4x64FullVersion"
                     Win64="yes" />
    <PackageGroup Id="Netfx4Full">
        <ExePackage Id="Netfx4Full"
              Cache="no"
              Compressed="yes"
              PerMachine="yes"
              Permanent="yes"
              Vital="yes"
              SourceFile="$(var.ProjectDir)dotNetFx40_Full_x86_x64.exe"
              DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
              DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" />
    </PackageGroup>

    <PackageGroup Id="Netfx403Update">
        <ExePackage Id="Netfx403Update"
              Cache="no"
              Compressed="yes"
              PerMachine="yes"
              Permanent="yes"
              Vital="yes"
              SourceFile="$(var.ProjectDir)NDP40-KB2600211-x86-x64.exe" 
              DetectCondition="Netfx4FullVersion AND (Netfx4FullVersion &lt;&lt; &quot;4.0.3&quot; OR Netfx4FullVersion &lt;&lt; &quot;4.5&quot;)" />
    </PackageGroup>
</Fragment>
Run Code Online (Sandbox Code Playgroud)

该条件扩展到Netfx4FullVersion AND (Netfx4FullVersion << "4.0.3" OR Netfx4FullVersion << "4.5")没有 XML 转义。

以下文章很有帮助:

捆绑骨架代码

捆绑包清单

使用 WiX 变量定义搜索

将包链接成捆绑包

如何检查 .Net 版本