在.NET Core中使用共享库

编程入门 行业动态 更新时间:2024-10-28 09:22:20
本文介绍了在.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": "*" }, "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\LinqToTwitter.Shared.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中使用共享库

本文发布于:2023-11-04 11:23:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!