.NET Core - 自包含部署不工作

.NET Core - Self Contained Deployment not working

我有一个 .NET Core Web 应用程序。我正在使用 publish command to create a self contained deployment

它会创建文件并似乎会创建 .net 核心 dll,但是当在 Windows 10 上的 IIS 中运行时,我仍然需要安装 .NET Core Runtime 才能使其正常工作。安装 .NET Core 托管包后,它工作正常。

我问了很多其他帖子,但找不到答案。

默认情况下,IIS 给出以下错误:

HTTP ERROR 500.19 – Internal Server Error

我的发布命令:

dotnet publish "mydirectory\mywebsite.csproj" --self-contained --framework netcoreapp2.1 -r win10-x64 -c Release

csproj 看起来像这样:

 <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <UserSecretsId>aspnet-mywebsite-656GASF8-B9H4-5963-1038-5D735B609E15</UserSecretsId>
      <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
  </PropertyGroup>

这是已发布的文件。

我以为 'l1-1-0' 部分可能是错误的框架版本,但我的 dotnet 版本是 2.1.500。

请问我需要做什么才能让它工作?

Lex Li 的评论/ blog post 包含答案。我在这里详细说明是为了避免其他人因为这个简单的误解而浪费时间。

A self contained deployment does indeed include the runtime, but it doesn't include the ASP.NET Core module for IIS which you get when you download the Runtime & Hosting Bundle from the .net downloads page.

因此,如果您要部署到 IIS,即使是自包含部署,您也需要 运行 Runtime & Hosting Bundle 安装程序。

自包含部署仅意味着应用程序将使用与应用程序一起打包的 .NET Core 运行时,而不是计算机上安装的任何内容。