如何确定 Windows 服务器上是否安装了 asp.net core [英] How to determine if asp.net core has been installed on a windows server

查看:38
本文介绍了如何确定 Windows 服务器上是否安装了 asp.net core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm setting up various windows servers to host asp.net core apps, and I need to be able to determine if they have the asp.net hosting bundle installed.

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

在服务器上安装 .NET Core Windows Server Hosting 包.该捆绑包将安装 .NET Core 运行时、.NET Core 库和ASP.NET 核心模块.该模块在两者之间创建反向代理IIS 和 Kestrel 服务器."

"Install the .NET Core Windows Server Hosting bundle on the server. The bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server."

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

I'm setting up a deployment, and I need to make sure my server is configured so I can run asp.net core apps.

基本上,我正在寻找注册表项或其他方式来告诉我是否应该运行安装程序设置.(类似于我们判断是否安装了旧版本框架的方式,例如https://support.microsoft.com/en-us/kb/318785适用于早期版本)

I'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'd tell if older versions of the framework are installed, like https://support.microsoft.com/en-us/kb/318785 does for earlier versions)

推荐答案

可以使用powershell检查宿主模块是否注册到IIS

You can use powershell to check if the hosting module is registered with IIS

在本地 powershell 会话中

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" }}

这篇关于如何确定 Windows 服务器上是否安装了 asp.net core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆