Netstandard1.x Nuget packages cannot be installed for netstandard1.x projects

自闭症网瘾萝莉.ら 提交于 2019-12-03 22:44:19
zone117x

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.

Cam Moten

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!