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

时间:2017-01-16 21:01:15

标签: .net .net-standard

为帮助重现此问题,需要执行以下步骤在Visual Studio 2015中创建.NETStandard1.6 PCL:

  1. 创建一个新的类库(适用于iOS,Android和Windows的便携版)。
  2. 在“属性”页面中,单击“#34; Target .NET Platform Standard"。
  3. 将.NETStandard表格.NETStandard1.1更改为.NETStandard1.6
  4. 构建此空项目。
  5. 发生以下错误:

    >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":{}

    都没有效果。

2 个答案:

答案 0 :(得分:6)

对于.csproj文件末尾的VS2015,添加:

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

答案 1 :(得分:0)

我遇到了同样的错误,我在project.json

中添加了以下内容
"frameworks": {
            "netstandard1.4": {
                "imports": "portable-net45+win8+wpa81+wp8"
            }
            "netplatform50": {}
  }

这对我有用

相关问题