Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 2: missing ApplicationInsights

I am publishing ASP.NET Core 2 application and seeing the following error.

Error:
  An assembly specified in the application dependencies manifest (MyApp.deps.json) was not found:
    package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
    path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'

  This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
    aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml

I did not see this error in Dev environment. So not sure what went wrong. Any ideas on how to fix this?

Update

I installed the SDK (I had only runtime installed) and everything started working. Not sure if this is the best solution though.

like image 562
nomad Avatar asked Sep 29 '17 15:09

nomad


People also ask

How do I add application insights to Web API?

Add Application Insights automatically From within your ASP.NET web app project in Visual Studio: Select Project > Add Application Insights Telemetry > Application Insights Sdk (local) > Next > Finish > Close.

What is telemetry in .NET core?

NET Core agents use telemetry to collect usage data. Telemetry is collected when an instrumented application first loads the agent's sensors and then periodically (every few hours) afterwards. Your privacy is important to us. The telemetry feature doesn't collect application data.


3 Answers

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.

like image 195
natemcmaster Avatar answered Oct 15 '22 11:10

natemcmaster


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.

like image 40
pallxk Avatar answered Oct 15 '22 12:10

pallxk


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.

like image 11
Jpsy Avatar answered Oct 15 '22 12:10

Jpsy