无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包 [英] Netstandard1.x Nuget packages cannot be installed for netstandard1.x projects

查看:32
本文介绍了无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 .netstandard 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 包.netstandard1.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(一个支持 .netstandard 的项目)的源代码来验证我没有设置我的项目错了,我遇到了同样的问题:

I just trying pulling and building the source for MailKit (a project that supports .netstandard) 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.

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

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

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

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

推荐答案

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

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

Download the latest nuget commandline util from here https://dist.nuget.org/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 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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