gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 04:48:53 29 4
gpt4 key购买 nike

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

Restoring packages for 'ClassLibrary1'.
Restoring packages for c:\users\zone1\documents\visual studio 2015\Projects\ClassLibrary1\ClassLibrary1\project.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 和其他版本也是如此。

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

Errors in C:\Users\zone1\Repos\MailKit\MailKit\MailKit.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

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

最佳答案

感谢 @eddie-msft 的提示,找到了可行的解决方案.

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

然后运行:

nuget.exe locals -clear all

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

我发现这个问题发生在任何全新安装 Windows/VS/tooling 的系统上,很可能是安装程序的错误。

关于c# - 无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39584699/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com