Error for .NETStandard1.6 PCL: “Your project is not referencing the ”.NETPlatform,Version=v5.0“ framework”

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

To help reproduce the problem, the following steps are taken to create a .NETStandard1.6 PCL in Visual Studio 2015:

  1. Create a new Class Library(Portable for iOS, Android and Windows).
  2. In its Properties page, click "Target .NET Platform Standard".
  3. Change .NETStandard form .NETStandard1.1 to .NETStandard1.6
  4. Build this empty project.

The following error occurs:

>C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets(140,5): error : Your project is not referencing the ".NETPlatform,Version=v5.0" framework. Add a reference to ".NETPlatform,Version=v5.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. 

The following is project.json:

{   "supports": {},   "dependencies": {     "Microsoft.NETCore.Portable.Compatibility": "1.0.1",     "NETStandard.Library": "1.6.0"   },   "frameworks": {     "netstandard1.6": {}   } } 

Could anyone offer a tip on how to Add a reference to ".NETPlatform,Version=v5.0" in the "frameworks" section? I tried the following:

"donet5.4": {}

"donet5.0": {}

Neither works.

回答1:

For VS2015 at the very end of the .csproj file, add:

<PropertyGroup>     <NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker> </PropertyGroup> 


回答2:

I had the same error, I added the following in my project.json

"frameworks": {             "netstandard1.4": {                 "imports": "portable-net45+win8+wpa81+wp8"             }             "netplatform50": {}   } 

This worked for me



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