.NETStandard1.6 PCL 的错误: "您的项目没有引用 ".NETPlatform,Version=v5.0" 框架"

4
为了帮助重现问题,按照以下步骤在Visual Studio 2015中创建.NETStandard1.6 PCL:
  1. 创建一个新的类库(可移植的,适用于iOS、Android和Windows)。
  2. 在其属性页面中,点击“目标.NET平台标准”。
  3. 将.NETStandard从.NETStandard1.1更改为.NETStandard1.6
  4. 构建这个空项目。
接下来会出现以下错误:
>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.

以下是project.json文件:
{
  "supports": {},
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.6": {}
  }
}

有人可以提供一个提示如何在“框架”部分中添加对“.NETPlatform,Version = v5.0”的引用吗?我尝试了以下内容:

“donet5.4”:{}

“donet5.0”:{}

两者都不起作用。


1
告别那个吧,转用VS2017。 - Lex Li
我很期待使用VS2017,但还需要再等几周。这些评论并没有什么帮助。 - Stonetip
2个回答

7

对于VS2015,在.csproj文件的末尾添加以下内容:

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

0

我遇到了同样的错误,我在我的project.json中添加了以下内容

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

这对我有用


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接