【问题标题】:VS 2017 RC - Core Projects - ClassLibrary and Console - Frameworks differVS 2017 RC - 核心项目 - 类库和控制台 - 框架不同
【发布时间】:2016-11-28 20:28:51
【问题描述】:

我在 VS2017 RC 中创建了一个新项目,我添加了一个控制台库和一个类库。

现在我可以看到框架被添加为依赖项。

但是为什么核心控制台没有NetStandard.Library

我可以看到Microsoft.NetCore.app

因此,当我尝试使用 dotnet -run 启动控制台应用程序时

我收到此错误

[![在此处输入图片描述][2]][2]

【问题讨论】:

  • 您不能直接从提示中复制文本而不是发布图像吗?
  • 你的第二张图片没有上传

标签: .net-core visual-studio-2017


【解决方案1】:

因为您安装了 1.1.0 的 SDK/构建工具,但没有安装共享框架 1.1.0。
SDK 和共享框架不是一回事。

也许最好用 Linux 命令行来解释。 如果你有的话,你目前安装的是

apt-get install dotnet-dev-1.0.1

但你缺少的是

apt-get install dotnet-sharedframework-microsoft.netcore.app-1.1.0

更深层的原因是你有 apt-get install dotnet-dev-1.0.1

而不是

apt-get install dotnet-dev-1.1.0

SDK 1.1 版会安装共享框架 1.1.0,但如果你的 SDK 是 1.0.1,那么 1.1.0 从未安装过。

关于 netstandard 与 netcore,David Fowler 有一个很好的解释尝试 here
基本上,“.NET Core Framework”和“.NET Framework non-core”的每个版本都扩展了 netstandard 的一个版本,其中 netstandard-library 可以在 CORE 和 NON-Core 中使用):

具体来说,您的应用只能作为 .NET Core 或 .NET Framework 运行。没有 netstandard-app(当前),只有 netstandard-libraries。

NetFramework_vX 和 NetCoreFramework_vX 都是 NetStandardLibray_vX 的超集。

using System;

namespace Analogy
{
    // Each interface represents a target framework and methods represents groups of APIs available on that target framework. 
    // The goal is to show the relationship between .NET Standard API surface and other .NET platforms


    // .NET Standard

    interface INetStandard10
    {
        void Primitives();
        void Reflection();
        void Tasks();
        void Collections();
        void Linq();
    }

    interface INetStandard11 : INetStandard10
    {
        void ConcurrentCollections();
        void InteropServices();
    }

    interface INetStandard12 : INetStandard11
    {
        void ThreadingTimer();
    }

    interface INetStandard13 : INetStandard12
    {
        void FileSystem();
        void Console();
        void ThreadPool();
        void Process();
        void Sockets();

        void AsyncLocal();
    }

    interface INetStandard14 : INetStandard13
    {
        void IsolatedStorage();
    }

    interface INetStandard15 : INetStandard14
    {
        void AssemblyLoadContext();
    }

    // .NET Framework 

    interface INetFramework45 : INetStandard11
    {
        void FileSystem();
        void Console();
        void ThreadPool();
        void Crypto();
        void WebSockets();
        void Process();
        void Sockets();

        void AppDomain();
        void Xml();
        void Drawing();
        void SystemWeb();
        void WPF();
        void WindowsForms();
        void WCF();
    }

    interface INetFramework451 : INetFramework45, INetStandard12
    {
        // TODO: .NET Framework 4.5.1 specific APIs
    }

    interface INetFramework452 : INetFramework451, INetStandard12
    {
        // TODO: .NET Framework 4.5.2 specific APIs
    }

    interface INetFramework46 : INetFramework452, INetStandard13
    {
        // TODO: .NET Framework 4.6 specific APIs
    }

    interface INetFramework461 : INetFramework46, INetStandard14
    {
        // TODO: .NET Framework 4.6.1 specific APIs
    }

    interface INetFramework462 : INetFramework461, INetStandard15
    {
        // TODO: .NET Framework 4.6 specific APIs
    }

    // Mono

    interface IMono43 : INetFramework46
    {
        void MonoSpecificApi();
    }

    // Windows Universal Platform

    interface IWindowsUniversalPlatform : INetStandard14
    {
        void GPS();
        void Xaml();
    }

    // Xamarin 

    interface IXamarinIOS : INetStandard15
    {
        void AppleAPIs();
    }

    interface IXamarinAndroid : INetStandard15
    {
        void GoogleAPIs();
    }

    // .NET Core

    interface INetCoreApp10 : INetStandard15
    {

    }

    // Future platform

    interface ISomeFuturePlatform : INetStandard13
    {
        // A future platform chooses to implement a specific .NET Standard version.
        // All libraries that target that version are instantly compatible with this new
        // platform
    }
}

【讨论】:

    【解决方案2】:

    netcoreapp 和 netstandard 的区别请查看:What's the difference between the new netstandardapp and netcoreapp TFMs?

    当您在命令行上运行 dotnet -run 时,您需要安装 .NET Core SDK,它是 .NET Core 的单独安装。安装 VS2017 RC 不会安装这个 SDK。可以下载.NET Core 1.1 SDK here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-16
      • 2019-07-06
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      • 2018-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多