.net Core App 1.1 不将外部 .net 标准库解析为文件引用

.net Core App 1.1 doesn't resolve external .net standard libs as file reference

我创建了一个包含 2 个项目的解决方案,一个 .net core 1.1 主机(控制台)和一个 .net standard 1.6 class 库。

我将引用添加为项目引用。

然后在运行时我得到一个异常,即找不到客户端程序集。 首先,我使用了一种 .net 标准程序集 所以我的测试控制台看起来像这样微不足道:

 class Program
    {
        static void Main(string[] args)
        {
            var foo = new Class1();

当我将宿主项目切换到 .net core 1.0 时,一切正常。

我在这里发布了一个样本:https://github.com/Gentlehag/coreapp11bug

这是预期的行为吗?

哪个 .net 标准库版本应该与 .net core 1.1 兼容?

同时这里有一个讨论:https://github.com/dotnet/coreclr/issues/10037

解决方案:

.net core 目前完全不支持文件引用。尽管 ide 允许...

he .NET Core SDK v1.0 (Visual Studio 2017 RTM) doesn't support direct references to assemblies on disk. Basically the options that will give you success are either or .

We did enable this scenario for 2.0 though. See dotnet/sdk#120, but those bits have not been released yet. They will be when .NET Core 2.0 comes out later this year.

https://github.com/NuGet/Home/issues/4772#issuecomment-285394790

所以解决方案是包裹在 nuget 包中或创建一个添加所有现有项目的解决方案