如何防止 Asp.Net Core 从 Runtime Store 引用依赖项

How to prevent Asp.Net Core from referencing dependencies from Runtime Store

我在 Visual Studio 17.7 上使用 Asp.NET Core 2.1 开发 Web 应用程序,问题是当我将 Web 应用程序发布为依赖于框架的应用程序并尝试 运行 生产机器上的应用程序时,我收到此错误消息:

Error:
An assembly specified in the application dependencies manifest (Example.deps.json) was not found:
package: 'Cronos', version: '0.6.3'
path: 'lib/netstandard1.0/Cronos.dll'

Cronos.dll 是我在网络应用程序中使用的 Hangfire 库的依赖项,在 Example.deps.json 文件中我发现了这个:

"Cronos/0.6.3": {
    "dependencies": {
      "NETStandard.Library": "2.0.3"
    },
    "runtime": {
      "lib/netstandard1.0/Cronos.dll": {
        "assemblyVersion": "0.6.3.0",
        "fileVersion": "0.6.3.0"
      }
    },
    "compile": {
      "lib/netstandard1.0/Cronos.dll": {}
    }
  },

问题是它引用了 运行time store 中的库,这在 developemnt 机器上可以工作,但是当我部署到另一台机器时发生错误。

我已经尝试过本文中建议的解决方案:

https://docs.microsoft.com/en-us/dotnet/core/deploying/runtime-store

通过设置:-

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

我也尝试过解决这个 github 问题但没有成功:

https://github.com/dotnet/coreclr/issues/13542

部署 .NET Core 应用程序时,仅使用 bin/Release/netcoreapp*/publish…/netcoreapp*/{RID}/publish 的发布输出(使用 -r RID 选项时)或使用 dotnet publish 调用-o ../target-dir 指定发布目标位置的选项。

构建输出 (bin/Release/netcoreapp*) 仅用于开发目的,因为 runtimeconfig.dev.json 文件将 .NET Core 配置为直接使用来自 NuGet 包缓存的包,这避免了在开发构建期间复制资产.