.NetCoreApp 和 .NetStandard.Library 有什么区别? [英] What's difference between .NetCoreApp and .NetStandard.Library?

查看:25
本文介绍了.NetCoreApp 和 .NetStandard.Library 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.Net Core 1.0 已于几天前发布,我已开始使用它.我创建了一个简单的解决方案,一个项目(类库 => .NetStandard.Library)和第二个控制台应用程序(.NetCoreApp).关键是,控制台应用程序引用了库,但我不能使用该库的类型.这两个框架不兼容吗?我错过了什么吗?

.Net Core 1.0 has been released couple days ago, and i've started playing with it. I've created simple solution, with one project (class library => .NetStandard.Library) and second, console application (.NetCoreApp). The point is, console application has reference to library, but i cant use types form that library. Are those two frameworks incompatible? Am i missing something?

控制台应用程序的project.json:

project.json for console application:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "ConsoleApplicationLibrary": "1.0.0-*",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

库的project.json:

project.json for library:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

我已经弄清楚了,它可以工作,并且代码可以编译,但 Visual Studio 仍然将库中的类型突出显示为未知.

I've figured it out, that it works, and code compiles, but visual studio still highlights types from library as unknown.

推荐答案

.NetCoreApp 是一个平台,.NetStandard.Library 是一个应该是跨平台的库(可移植类库),适用于各种 .NET 平台运行时.

.NetCoreApp is a platform and .NetStandard.Library is a library supposed to be cross platform (portable class library) for various .NET platforms runtimes.

您可以在任何受支持的 .NET 平台项目中包含 NetStandard.Library 的直接引用(包),例如 .NETCoreApp (Dot Net Core 1.X)

You can include a direct reference (package) of NetStandard.Library in any of your .NET platform project that is supported, for ex .NETCoreApp (Dot Net Core 1.X)

参考:https://docs.microsoft.com/en-us/dotnet/articles/standard/library

这篇关于.NetCoreApp 和 .NetStandard.Library 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆