尝试从 docker 镜像运行我的应用程序时收到以下错误:
Error: assembly specified in the dependencies manifest was not found -- package: 'Microsoft.ApplicationInsights.AspNetCore', version: '1.0.2', path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
docker 镜像基于
microsoft/aspnetcore
。在 docker 镜像
dotnet restore
上使用 dotnet publish
和 microsoft/aspnetcore-build:1.1.0-projectjson
构建的文件在
"targets"
中的 {app}.deps.json
下,我有: "Microsoft.ApplicationInsights.AspNetCore/1.0.2": {
"dependencies": {
"Microsoft.ApplicationInsights": "2.1.0",
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.1",
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0",
"Microsoft.Extensions.Logging.Abstractions": "1.0.0",
"System.Net.NameResolution": "4.3.0"
},
"runtime": {
"lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll": {}
},
"compile": {
"lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll": {}
}
},
我发布的输出中没有
lib
文件夹,但我发布的输出的根目录中有 Microsoft.ApplicationInsights.AspNetCore
。我觉得我错过了一些明显的东西。任何帮助,将不胜感激。
更新:
将 Application Insights 更新到 2.0.0 无效。
删除 Application Insights 只是将问题转移到另一个程序集。
切换到独立部署无效。
添加了
COREHOST_TRACE=1
并收到以下输出:Processing TPA for deps entry [Microsoft.ApplicationInsights.AspNetCore, 2.0.0, lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll]
Considering entry [Microsoft.ApplicationInsights.AspNetCore/2.0.0/lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll] and probe dir [/packagescache/x64]
The hash file is invalid [/packagescache/x64/Microsoft.ApplicationInsights.AspNetCore/2.0.0/Microsoft.ApplicationInsights.AspNetCore.2.0.0.nupkg.sha512]
Skipping... match hash failed
Considering entry [Microsoft.ApplicationInsights.AspNetCore/2.0.0/lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll] and probe dir [/packagescache]
The hash file is invalid [/packagescache/Microsoft.ApplicationInsights.AspNetCore/2.0.0/Microsoft.ApplicationInsights.AspNetCore.2.0.0.nupkg.sha512]
Skipping... match hash failed
Error: assembly specified in the dependencies manifest was not found -- package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.0.0', path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
最佳答案
我通过执行在发布文件夹中找到的应用程序解决了这个问题。例如,如果您在 Ubuntu 16.04 的 Release模式下发布 .net core 1.1 应用程序,您发布的文件将位于
该目录中有一个可执行文件,但这不是您要使用的可执行文件。您实际上需要更深入一个目录并在其中使用可执行文件
关于docker - dotnet 发布后无法在 docker 镜像中找到 Application Insights 依赖项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42425249/