首页 文章

如何确定是否已在Windows服务器上安装asp.net核心

提问于
浏览
11

我正在设置各种Windows服务器来托管asp.net核心应用程序,我需要能够确定他们是否安装了asp.net托管包 .

https://docs.asp.net/en/latest/publishing/iis.html#install-the-net-core-windows-server-hosting-bundle说:

“在服务器上安装.NET Core Windows Server Hosting软件包 . 该软件包将安装.NET Core Runtime,.NET Core Library和ASP.NET核心模块 . 该模块在IIS和Kestrel之间创建反向代理服务器 . ”

我正在设置部署,我需要确保我的服务器已配置,以便我可以运行asp.net核心应用程序 .

我'm looking, basically, for a registry key or some other way to tell me if I should run the installer setup. (something like the way we'告诉你是否安装了旧版本的框架,比如早期版本的 https://support.microsoft.com/en-us/kb/318785

5 回答

  • 4

    您也可以双击DotNetCore.1.0.1-WindowsHosting.exe
    如果已安装.NET Core Windows Server Hosting包,则打开窗口将具有:

    • 修改设置标签

    • 修复和卸载按钮

    “修复”和“卸载”按钮以及“修改设置”标签 .

    Microsoft .NET Core 1.0.1 - Windows Server Hosting Setup already installed

  • 9

    您可以使用powershell检查托管模块是否已在IIS中注册

    在本地的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"
    }
    

    如果你想在远程会话中做替换前2行

    Invoke-Command -Session $Session {Import-module WebAdministration}
    $vm_dotnet_core_hosting_module = Invoke-Command -Session $Session {Get-WebGlobalModule | where-object { $_.name.ToLower() -eq "aspnetcoremodule" }}
    
  • 5

    你可以看看

    HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Uninstall

    并确保“Microsoft .NET Core 1.0.0 - Windows Server Hosting”在那里

  • 0

    如果允许引入约束,一种选择是仅允许“自包含应用程序”,因为它们不需要任何额外的安装 . 这也使“安装的版本”之类的问题消失了 .

    如果您需要支持“便携式应用程序”,只需执行以下操作即可检查dotnet.exe是否可用:

    where dotnet

    然后,您可以检查版本:

    dotnet --version

    这也可以让您在关注后检查.NET Core的版本 .

  • 0

    您可以在 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Updates\.NET Core 路径下搜索 Microsoft .NET Core 1.1.1 - Windows Server Hosting 注册表项,如下面的屏幕截图所示 .

    enter image description here

    您还可以使用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下载样本 .

相关问题