How to determine if asp.net core has been installed on a windows server
You can search Microsoft .NET Core 1.1.1 - Windows Server Hosting
registry key under HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Updates\.NET Core
path like screenshot below.
Also you can use PowerShell to determine the whether the key existed or not.
$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"
}
And you can download sample from How to determine ASP.NET Core installation on a Windows Server by PowerShell.
If you have .NET Core CLI installed, you can try:
dotnet --list-runtimes
Which will print something like:
Microsoft.NETCore.App 3.0.0 [c:\program files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [c:\program files\dotnet\shared\Microsoft.NETCore.App]
Reference: Microsoft doc
You can use powershell to check if the hosting module is registered with IIS
In the local powershell session
Import-module WebAdministration
$vm_dotnet_core_hosting_module = Get-WebGlobalModule | where-object { $_.name.ToLower() -eq "aspnetcoremodule" }
if (!$vm_dotnet_core_hosting_module)
{
throw ".Net core hosting module is not installed"
}
If you want to do in the remote session replace first 2 lines with
Invoke-Command -Session $Session {Import-module WebAdministration}
$vm_dotnet_core_hosting_module = Invoke-Command -Session $Session {Get-WebGlobalModule | where-object { $_.name.ToLower() -eq "aspnetcoremodule" }}