如何检查 Wix 工具集中是否安装了 IIS 和 .NET Core Hosting Bundle?

How to check are IIS and .NET Core Hosting Bundle installed in wix toolset?

如何检查 WiX 工具集安装程序中是否安装了 IIS 和 .NET Core 托管捆绑包?

通过检测注册表项,您会发现是否安装了 iis 和 .net 核心包:

<util:RegistrySearch Root="HKLM"
                     Key="SOFTWARE\Microsoft\InetStp\Components"
                     Value="W3SVC"
                     Variable="WebServer"/>

<ExePackage Id='IIS_WebServer'
            DisplayName='Installing IIS: IIS-WebServer'
            PerMachine='yes'
            SourceFile='.\Resources\Dism.exe'
            InstallCondition='NOT WebServer'
            InstallCommand='/Online /Enable-Feature /FeatureName:IIS-WebServer'>
</ExePackage>

以下是其他 iis 组件:

Discover Installed Components

另一种方法是您可以使用 Powershell 检查注册表项:

$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core"
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath
$NotInstalled = $True
$DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object {
    $NotInstalled = $False
    Write-Host "The host has installed $_"
}
If ($NotInstalled) {
    Write-Host "Can not find ASP.NET Core installed on the host"
}

How to determine ASP.NET Core installation on a Windows Server by PowerShell