5

I have an application that requires .Net 4.0.3 (link).

I've found this article which tells me where I would find the version of .Net which is installed but all I can find is the list of included properties that the WiX compiler recognises (here).

I've tried following the directions in this article, which tells me to use the following code, but this just installs .Net 4 without the update:

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

How would I go about making WiX check for the specific 4.0.3 update, either through a pre-defined WiX property or checking the registry value myself?

4

2 回答 2

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>

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

以下文章很有帮助:

捆绑骨架代码

捆绑包清单

使用 WiX 变量定义搜索

将包链接成一个包

如何检查 .Net 版本

于 2013-09-25T08:13:19.673 回答
3

对于 .net 4.0 ,注册表项中的版本值"SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"将始终为 4.0.30319(即使已安装更新)。

这是我在捆绑包中用于搜索是否已安装 .net 4.0.3 版本的代码:

<util:RegistrySearch Root="HKLM" 
    Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.3"
    Result="exists" 
    Variable="Netfx403" />
<util:RegistrySearch Root="HKLM"  
    Key="SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.3" 
    Result="exists"
    Variable="Netfx403x64"
    Win64="yes" />

然后在您的 ExePackage DetectCondition 中:

DetectCondition="Netfx403 AND (NOT VersionNT64 OR Netfx403x64)"
于 2014-11-27T08:22:28.260 回答