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:\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'.
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.
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:\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.
I've posted some more details here: https://github.com/NuGet/Home/issues/3433
This all worked before I reformatted with a fresh Windows installation. Am I missing something?
Got a working solution thanks to a tip from @eddie-msft.
Download the latest nuget commandline util from here https://dist.nuget.org/index.html (v3.5.0-rc1 at the time of posting)
Then run:
nuget.exe locals -clear all
I made sure to have VS closed and deleted any existing project.lock.json files. Now everything seems to work as intended.
I found this problem to occur on any system with a fresh installation of Windows/VS/tooling so likely a bug with their installers.
For VS 2017 - Update 15.3
You can get around this by doing the following
Edit the .csproj
File for the .NET Standard Library and add these lines
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.4' ">$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
Other stuff here
</Project>
PackageTargetFallback will allow you to use compatible packages that are older.
https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/
It looks like something is missed in your tooling, and the error messaging isn't always the clearest on this. Can you make sure that you have run both the installers here:
Visual Studio 2015 Update 3 (I'm guessing you have this)
.NET Core 1.0.1 - VS 2015 Tooling Preview 2
I really don't think it's a project file issue, as MailKit is failing for you, and I doubt you broke NuGet. The other bit that might give you some good information if this doesn't work is to run
Dotnet restore
in the project directory to see how donet handles it without Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With