无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包

编程入门 行业动态 更新时间:2024-10-26 16:23:08
本文介绍了无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在全新安装 Windows 10 以及最新的 Visual Studio 2015、netcore 和 nuget 工具后 - 我无法再将 Nuget 包安装到任何 standard 项目.这是一些示例输出:

After doing a fresh Windows 10 installation along with latest Visual Studio 2015, netcore, and nuget tooling - I can no longer install Nuget packages to any standard projects. Here's some example output:

Restoring packages for 'ClassLibrary1'. Restoring packages for c:userszone1documentsvisual studio 2015ProjectsClassLibrary1ClassLibrary1project.json... Package System.ComponentModel.EventBasedAsync 4.0.11 is not compatible with netstandard1.3 (.NETStandard,Version=v1.3). Package System.ComponentModel.EventBasedAsync 4.0.11 supports: - monoandroid10 (MonoAndroid,Version=v1.0) - monotouch10 (MonoTouch,Version=v1.0) - net45 (.NETFramework,Version=v4.5) - netcore50 (.NETCore,Version=v5.0) - netstandard1.0 (.NETStandard,Version=v1.0) - netstandard1.3 (.NETStandard,Version=v1.3) - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259) - win8 (Windows,Version=v8.0) - wp8 (WindowsPhone,Version=v8.0) - wpa81 (WindowsPhoneApp,Version=v8.1) - xamarinios10 (Xamarin.iOS,Version=v1.0) - xamarinmac20 (Xamarin.Mac,Version=v2.0) - xamarintvos10 (Xamarin.TVOS,Version=v1.0) - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0) One or more packages are incompatible with .NETStandard,Version=v1.3. Package restore failed for 'ClassLibrary1'.

我创建了项目 ClassLibrary1 作为可移植的类库,将目标更改为 netstandard1.3,并且无法安装任何显示支持 netstandard1.3 的 Nuget 包standard1.5 和其他版本也是如此.

I created the project ClassLibrary1 as a portable class library, change the target to netstandard1.3, and cannot install any Nuget packages that show support for netstandard1.3. Same goes for netstandard1.5 and the other versions.

我只是尝试拉取和构建 MailKit(一个支持 standard 的项目)的源代码来验证我没有设置我的项目错了,我遇到了同样的问题:

I just trying pulling and building the source for MailKit (a project that supports standard) to verify I wasn't setting up my project wrong and am getting the same problem:

Errors in C:Userszone1ReposMailKitMailKitMailKit.CoreFX.xproj Package System.Net.NetworkInformation 4.1.0 is not compatible with netstandard1.3 (.NETStandard,Version=v1.3). Package System.Net.NetworkInformation 4.1.0 supports: - monoandroid10 (MonoAndroid,Version=v1.0) - monotouch10 (MonoTouch,Version=v1.0) - net45 (.NETFramework,Version=v4.5) - netcore50 (.NETCore,Version=v5.0) - netstandard1.0 (.NETStandard,Version=v1.0) - netstandard1.3 (.NETStandard,Version=v1.3) - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259) - win8 (Windows,Version=v8.0) - wp8 (WindowsPhone,Version=v8.0) - wpa81 (WindowsPhoneApp,Version=v8.1) - xamarinios10 (Xamarin.iOS,Version=v1.0) - xamarinmac20 (Xamarin.Mac,Version=v2.0) - xamarintvos10 (Xamarin.TVOS,Version=v1.0) - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0) One or more packages are incompatible with .NETStandard,Version=v1.3.

我在这里发布了更多详细信息:github/NuGet/Home/issues/3433

I've posted some more details here: github/NuGet/Home/issues/3433

在我用全新的 Windows 安装重新格式化之前,这一切都奏效了.我错过了什么吗?

This all worked before I reformatted with a fresh Windows installation. Am I missing something?

推荐答案

感谢来自 @eddie 的提示,得到了一个可行的解决方案-msft.

从这里下载最新的 nuget 命令行工具 dist.nuget/index.html (v3.5.0-rc1发帖时)

Download the latest nuget commandline util from here dist.nuget/index.html (v3.5.0-rc1 at the time of posting)

然后运行:

nuget.exe locals -clear all

我确保关闭了 VS 并删除了所有现有的 project.lock.json 文件.现在一切似乎都按预期工作.

I made sure to have VS closed and deleted any existing project.lock.json files. Now everything seems to work as intended.

我发现此问题在任何全新安装 Windows/VS/工具的系统上都会发生,因此很可能是安装程序存在错误.

I found this problem to occur on any system with a fresh installation of Windows/VS/tooling so likely a bug with their installers.

更多推荐

无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包

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

发布评论

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

>www.elefans.com

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