ASP.NET Core 2: missing ApplicationInsights

Make sure your project have matching versions for Microsoft.NETCore.App (your project target framework) and Microsoft.AspNetCore.All (NuGet dependency included by default for .NET Core 2.0 projects) or Microsoft.AspNetCore.App (for .NET Core 2.1+ projects).

If you've ever updated your project target framework from .NET Core 2.0 to .Net Core 2.1, remember to update your NuGet dependencies accordingly, as they won't got updated automatically.


This assembly was expected to be in the local runtime store

You are getting this error because you don't have the ASP.NET Core Runtime Store installed. You have two options to fix this.

  1. Install the ASP.NET Core Runtime Store. It comes bundled with the .NET Core SDK, which is why installing the SDK fixed this. You can also install just the store, without the SDK, by downloading it here: https://www.microsoft.com/net/download/all.

  2. Don't use runtime store trimming. You can disable the trimming by setting this property in your csproj file.

    <PropertyGroup>
        <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
    </PropertyGroup>

You can also pass this in on command line.

dotnet publish /property:PublishWithAspNetCoreTargetManifest=false

Update: June 25, 2018

This answer only applies to ASP.NET Core 2.0 projects. In ASP.NET Core 2.1, there is no runtime store anymore.


This problem is discussed in great detail here: https://github.com/dotnet/coreclr/issues/13542 It seems to be related to updating Microsoft.AspNetCore.All to version 2.0.3 or higher in your project.

Following the above discussion it seems that for some time a solution was to install the latest .NET Core SDK on the hosting machine. But at least with the current SDK 2.1.300 this did not solve the problem for me.

The solution for me was, to add the following line to the .csproj of my main project:

  <PropertyGroup>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
  </PropertyGroup>

With this line ALL framework dependencies will be packed into the publishing folder! The published data of one of my projects grew from 15 Mb to 55 Mb with this switch. But at least this works, until there is a better solution.