c# - 如何从 wix 安装具有 .NET Core 运行时先决条件的网络核心应用程序

标签 c# .net-core wix burn wix3.11

由于 .NET Core 没有与 Netfx.wixext 等效的 Wix(即指定内置 Id 来检测和需要运行时),我似乎无法找到一种方法来正确安装 .NET Core 并考虑各种问题诸如同一版本系列中存在较新版本的情况(即 3.1)。

我尝试在刻录项目中直接使用 .NET Core 安装程序可执行文件,但出现的问题是检测似乎只能通过目录或文件搜索来实现。这导致无法正确检测构建版本差异,因为我无法检测“3.1.*”。

我尝试为 Wix Bundle 构建自定义操作,以便根据已安装的 .NET Core 版本以编程方式检测和设置属性 - 但我当然意识到 Burn 包无法具有自定义操作。

我还需要哪些其他选项来安装运行时并检测同一 .NET Core 系列(主要.次要)的 future 版本?

这是相关的wix代码片段:

<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <Fragment>
      <Variable Name="DotnetCoreRuntime31InstallDir" Value="[ProgramFiles64Folder]dotnet\shared\Microsoft.NETCore.App\3.1.12" />
      <util:DirectorySearch Id="DotnetCoreRuntime31Installed" Path="[DotnetCoreRuntime31InstallDir]" Variable="DotnetCoreRuntime31Installed" Result="exists" />
      <WixVariable Id="DotnetCoreRuntime31WebDetectCondition" Value="DotnetCoreRuntime31Installed" Overridable="yes" />
      <WixVariable Id="DotnetCoreRuntime31WebInstallCondition" Value="" Overridable="yes" />


      <Variable Name="AspNetCoreRuntime31InstallDir" Value="[ProgramFiles64Folder]dotnet\shared\Microsoft.AspNetCore.App\3.1.12" />
      <util:DirectorySearch Id="AspNetCoreRuntime31Installed" Path="[AspNetCoreRuntime31InstallDir]" Variable="AspNetCoreRuntime31Installed" Result="exists" />
      <WixVariable Id="AspNetCoreRuntime31WebDetectCondition" Value="AspNetCoreRuntime31Installed" Overridable="yes" />
      <WixVariable Id="AspNetCoreRuntime31WebInstallCondition" Value="" Overridable="yes" />
      
      <PackageGroup Id="AllNetCoreRuntime31">
        
        <ExePackage
            Name="dotnet-runtime-3.1.12-win-x64.exe"
            SourceFile="Resources\dotnet-runtime-3.1.12-win-x64.exe"
            InstallCommand="/install /quiet /norestart /log &quot;[DotnetCoreRuntime31Log]&quot;"
            RepairCommand="/repair /quiet /norestart /log &quot;[DotnetCoreRuntime31Log]&quot;"
            UninstallCommand="/uninstall /quiet /norestart /log &quot;[DotnetCoreRuntime31Log]&quot;"
            PerMachine="yes"
            DetectCondition="!(wix.DotnetCoreRuntime31WebDetectCondition)"
            InstallCondition="!(wix.DotnetCoreRuntime31WebInstallCondition)"
            Vital="yes"
            Permanent="yes"
            Protocol="burn"
            LogPathVariable="DotnetCoreRuntime31Log"
            Compressed="yes" />

          <ExePackage
            Name="aspnetcore-runtime-3.1.12-win-x64.exe"
            SourceFile="Resources\aspnetcore-runtime-3.1.12-win-x64.exe"
            InstallCommand="/install /quiet /norestart /log &quot;[AspNetCoreRuntime31Log]&quot;"
            RepairCommand="/repair /quiet /norestart /log &quot;[AspNetCoreRuntime31Log]&quot;"
            UninstallCommand="/uninstall /quiet /norestart /log &quot;[AspNetCoreRuntime31Log]&quot;"
            PerMachine="yes"
            DetectCondition="!(wix.AspNetCoreRuntime31WebDetectCondition)"
            InstallCondition="!(wix.AspNetCoreRuntime31WebInstallCondition)"
            Vital="yes"
            Permanent="yes"
            Protocol="burn"
            LogPathVariable="AspNetCoreRuntime31Log"
            Compressed="yes">   
        </ExePackage>
      </PackageGroup>
    </Fragment>
    
</Wix>

最佳答案

  1. 我们希望将此功能内置到 v4 - https://github.com/wixtoolset/issues/issues/6257https://github.com/wixtoolset/issues/issues/6264 .

  2. 目前,由于 .NET Core 的版本控制是可预测的,并且具有预定义的支持窗口和发布节奏,因此您可以通过搜索所有 36 个左右的可能版本来进行强力搜索。

  3. 您可以通过编写自定义 BootstrapperApplication 来运行 bundle 中的代码。如果您使用内置 BA wixstdba,它有一个名为 BAFunctions 的扩展点,您可以在其中编写自己的( native ).dll。

关于c# - 如何从 wix 安装具有 .NET Core 运行时先决条件的网络核心应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67024261/

相关文章:

wix - 将命令行参数传递给 WiX 自定义操作

WiX:如何使用 SolutionDir 的相对路径

c# - Visual Studio 2013 构建缓慢 启动缓慢

c# - 如何为不同的子类实现接口(interface)的多个实例?

c# - 错误 MSB4019 : The imported project "C:\Program Files\dotnet\sdk\1.0.3\Microsoft\Portable\v5.0\Microsoft.Portable.CSharp.targets" was not found

c# - 限制与外部 API 的传出连接

wix - 在 WiX 自定义 Bootstrap UI 中访问安装程序包信息

c# - 分组同类对象 C#

c# - LayoutAwarePage 的 MVVM 够用吗?

c# - 如何使用默认浏览器在 C# 中打开带有 anchor (#) 的 html 文件