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

查看:60
本文介绍了.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平台项目中(例如,.NETCoreApp(点Net Core 1.X))包含NetStandard.Library的直接引用(程序包)

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/zh-我们/dotnet/articles/standard/library

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

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