由于 .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 "[DotnetCoreRuntime31Log]""
RepairCommand="/repair /quiet /norestart /log "[DotnetCoreRuntime31Log]""
UninstallCommand="/uninstall /quiet /norestart /log "[DotnetCoreRuntime31Log]""
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 "[AspNetCoreRuntime31Log]""
RepairCommand="/repair /quiet /norestart /log "[AspNetCoreRuntime31Log]""
UninstallCommand="/uninstall /quiet /norestart /log "[AspNetCoreRuntime31Log]""
PerMachine="yes"
DetectCondition="!(wix.AspNetCoreRuntime31WebDetectCondition)"
InstallCondition="!(wix.AspNetCoreRuntime31WebInstallCondition)"
Vital="yes"
Permanent="yes"
Protocol="burn"
LogPathVariable="AspNetCoreRuntime31Log"
Compressed="yes">
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
最佳答案
我们希望将此功能内置到 v4 - https://github.com/wixtoolset/issues/issues/6257和 https://github.com/wixtoolset/issues/issues/6264 .
目前,由于 .NET Core 的版本控制是可预测的,并且具有预定义的支持窗口和发布节奏,因此您可以通过搜索所有 36 个左右的可能版本来进行强力搜索。
您可以通过编写自定义 BootstrapperApplication 来运行 bundle 中的代码。如果您使用内置 BA
wixstdba
,它有一个名为 BAFunctions 的扩展点,您可以在其中编写自己的( native ).dll。
关于c# - 如何从 wix 安装具有 .NET Core 运行时先决条件的网络核心应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67024261/