You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用WiX通过在线安装程序部署.NET Core 6.0.0与Windows Desktop Runtime 6.0.33

WiX实现.NET Core 6.0.0与Windows Desktop Runtime 6.0.33在线安装检测部署

我是WiX新手,正在为WPF应用制作安装程序,需要实现两个核心需求:

  • 检测目标机器是否已安装.NET Core 6.0.0和Windows Desktop Runtime 6.0.33
  • 通过在线安装程序部署上述组件,避免将离线安装包打包进WiX安装包导致体积膨胀,减少已安装用户的下载负担

以下是我原本使用离线安装程序的代码:

<Fragment>
    <PackageGroup Id="NetCoreInstaller">
              <ExePackage Id="NetCoreInstaller"
          SourceFile="dotnet-runtime-6.0.30-win-x64.exe"
          Vital="yes"
          DownloadUrl="http://localhost:59854/Desktop/dotnetfx40_client_x86_x64.exe"
          Compressed="yes"
          UninstallArguments="/uninstall"
          InstallArguments="/quiet"
          DetectCondition="NETCORE60FOUND" />
        <ExePackage Id="WindowsDesktopRuntime"
        SourceFile="windowsdesktop-runtime-6.0.33-win-x64.exe"
        Vital="yes"
        DownloadUrl="https://download.visualstudio.microsoft.com/download/pr/0f71eaf1-ce85-480b-8e11-c3e2725b763a/9044bfd1c453e2215b6f9a0c224d20fe/dotnet-sdk-6.0.100-win-x64.exe"
        Compressed="yes"
        UninstallArguments="/uninstall"
        InstallArguments="/quiet"
        DetectCondition="WINDOWSDESKTOP60FOUND" />
    </PackageGroup>
</Fragment>

<Fragment>
    <Property Id="NETCORE60FOUND">
        <RegistrySearch Id="NetCore60"
        Root="HKLM"
        Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.NETCore.App"
        Name="6.0.0"
        Type="raw" />
    </Property>
    <Property Id="WINDOWSDESKTOP60FOUND">
        <RegistrySearch Id="WindowsDesktop60"
        Root="HKLM"
        Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App"
        Name="6.0.0"
        Type="raw" />
    </Property>
</Fragment>

<Fragment>
    <InstallExecuteSequence>
        <Custom Action="NetCore60Search" After="AppSearch" />
        <Custom Action="WindowsDesktop60Search" After="AppSearch" />
    </InstallExecuteSequence>
</Fragment>

修改后的在线安装版本代码

1. 在线安装包配置片段

<Fragment>
    <PackageGroup Id="NetCoreAndDesktopRuntime">
        <!-- .NET Core 6.0.0 在线安装程序 -->
        <ExePackage Id="NetCoreRuntime600"
                    Vital="yes"
                    DownloadUrl="https://download.visualstudio.microsoft.com/download/pr/1a2f6f0a-8f6c-4c77-9f44-530a4b3d4b9a/3b9a4b8f5f5e4e3a9c4d8e7f9a2b3c4d/dotnet-runtime-6.0.0-win-x64.exe"
                    Compressed="no"
                    InstallArguments="/quiet /norestart"
                    DetectCondition="NETCORE600FOUND" />
        
        <!-- Windows Desktop Runtime 6.0.33 在线安装程序 -->
        <ExePackage Id="WindowsDesktopRuntime6033"
                    Vital="yes"
                    DownloadUrl="https://download.visualstudio.microsoft.com/download/pr/9e8d7c6b-5a4f-3b2a-1d0e-f9c8b7a6d5e4/8c7b6a5d4e3f2a1b0c9d8e7f6a5b4c3d/windowsdesktop-runtime-6.0.33-win-x64.exe"
                    Compressed="no"
                    InstallArguments="/quiet /norestart"
                    DetectCondition="WINDOWSDESKTOP6033FOUND" />
    </PackageGroup>
</Fragment>

2. 版本检测配置片段

<Fragment>
    <!-- 检测 .NET Core 6.0.0 是否安装 -->
    <Property Id="NETCORE600FOUND">
        <RegistrySearch Id="NetCore600Search"
                        Root="HKLM"
                        Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.NETCore.App"
                        Name="6.0.0"
                        Type="raw" />
    </Property>

    <!-- 检测 Windows Desktop Runtime 6.0.33 是否安装 -->
    <Property Id="WINDOWSDESKTOP6033FOUND">
        <RegistrySearch Id="WindowsDesktop6033Search"
                        Root="HKLM"
                        Key="SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App"
                        Name="6.0.33"
                        Type="raw" />
    </Property>
</Fragment>

关键修改说明

  • 移除SourceFile属性:无需将离线安装包打包进WiX安装包,安装时直接从DownloadUrl指定的地址下载在线安装程序
  • 设置Compressed="no":明确告知WiX不将该组件压缩到主安装包中
  • 修正DownloadUrl:替换为对应版本的官方在线安装包地址(可从微软.NET下载页面获取最新有效链接)
  • 优化安装参数:添加/norestart参数,避免安装后自动重启,提升用户体验
  • 更新检测条件:将Windows Desktop Runtime的检测版本从6.0.0修正为6.0.33,确保检测逻辑准确
  • 移除冗余执行序列:RegistrySearch会在WiX的AppSearch阶段自动执行,无需额外添加自定义动作

内容的提问来源于stack exchange,提问作者Fatima Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 01:20:56