Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core - Self Contained Deployment not working

I have a .NET Core Web Application. I'm using the publish command to create a self contained deployment.

It creates the files and appears to create .net core dlls, but when runnning in IIS on Windows 10, I still need to install the .NET Core Runtime to get it to work. After installing .NET Core Hosting bundle it works fine.

I have reviewed a lot of other posts before asking, but can't find the answer.

By default IIS gives the following error:

HTTP ERROR 500.19 – Internal Server Error

My Publish command:

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

The csproj looks like this:

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

Here are the published files.

enter image description here

I thought maybe the 'l1-1-0' part might be the wrong framework version, but my dotnet version is 2.1.500.

enter image description here

What do I need to do to get it to work please?

like image 365
JsAndDotNet Avatar asked Jan 09 '19 15:01

JsAndDotNet


People also ask

What is self contained deployment .NET core?

Self-Contained deployment is a new deployment option that was added in . NET Core. In this mode, you compile platform specific code that is ready to run standalone in a specific target environment.

Is a non self contained executable a non self contained executable Cannot be referenced by a self contained executable?

The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable.


1 Answers

Lex Li's comment/ blog post contains the answer. I'm detailing it here to try to save someone else losing days to this simple misunderstanding.

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.

So if you are deploying to IIS, you will need to run the Runtime & Hosting Bundle installer even for a self contained deployment.

A self contained deployment just means the application will use the .NET Core Runtime packaged with the application rather than whatever is installed on the machine.

like image 103
JsAndDotNet Avatar answered Oct 06 '22 19:10

JsAndDotNet