ASP.NET Core 2:缺少ApplicationInsights

问题描述:

我正在发布ASP.NET Core 2应用程序,并看到以下错误.

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?

更新

我安装了SDK(我只安装了运行时),一切开始正常工作.不确定这是否是最好的解决方案.

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

该程序集应该在本地运行时存储区中

This assembly was expected to be in the local runtime store

由于没有安装ASP.NET Core 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. 安装ASP.NET Core运行时存储.它与.NET Core SDK捆绑在一起,这就是为什么安装SDK可以解决此问题的原因.您也可以通过在以下位置下载而无需SDK来仅安装商店: https://www. microsoft.com/net/download/all .

不使用运行时存储修剪.您可以通过在csproj文件中设置此属性来禁用修整.

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

更新:2018年6月25日

此答案仅适用于ASP.NET Core 2.0项目.在ASP.NET Core 2.1中,不再有运行时存储.

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