在.NET Core中使用共享库 [英] Using Shared Libraries with .NET Core

查看:47
本文介绍了在.NET Core中使用共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了我的开源库 LINQ to Twitter ,并使用共享库来最大程度地减少部署工件和处理平台的特定功能.我想支持.NET Core,并且认为最快的方法是引用共享库.添加引用"对话框未显示共享库,因此我尝试了project.json:

I wrote my open source library, LINQ to Twitter, with shared libraries to minimize deployment artifacts and handle platform specific features. I want to support .NET Core and am thinking that the fastest approach would be to reference the shared libraries. The Add References dialog didn't show the shared libraries, so I tried project.json:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "LinqToTwitter.Shared": "*",
    "LinqToTwitter.Shared.net": "*"
  },

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

我尝试了几种版本组合,但没有成功.错误消息包含以下内容:

I tried a few combinations of versions, but didn't get anywhere. The error messages contain something like this:

依赖项LinqToTwitter.Shared> = *无法解析.

The dependency LinqToTwitter.Shared >= * could not be resolved.

接下来,我打开* .xproj并将以下导入"粘贴到项目"部分:

Next, I opened the *.xproj and pasted the following Imports into the Project section:

<Import Project="..\LinqToTwitter.Shared\LinqToTwitter.Shared.projitems"
        Label="Shared" />
<Import 
  Project="..\LinqToTwitter.Shared.net\LinqToTwitter.Shared.net.projitems" 
  Label="Shared" />

这不会显示VS中的引用,也不会显示元数据中的任何内容,并且(如下所示)无法从引用.NET核心应用程序的控制台应用程序中引用任何共享库类型.

This doesn't show references in VS, nothing in metadata, and (as it would follow) can't reference any shared library types from a console app that references the .NET core app.

推荐答案

好消息-Visual Studio 2017现在允许.NET Core库项目引用共享项目.

Good news - Visual Studio 2017 now allows .NET Core library projects to reference Shared projects.

这篇关于在.NET Core中使用共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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