【问题标题】:Error for .NETStandard1.6 PCL: "Your project is not referencing the ".NETPlatform,Version=v5.0" framework".NETStandard1.6 PCL 错误:“您的项目未引用“.NETPlatform,Version=v5.0”框架”
【发布时间】:2017-06-08 04:48:37
【问题描述】:

为帮助重现问题,采取以下步骤在 Visual Studio 2015 中创建 .NETStandard1.6 PCL:

  1. 创建一个新的类库(适用于 iOS、Android 和 Windows)。
  2. 在其“属性”页面中,单击“Target .NET Platform Standard”。
  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”:{}

都不行。

【问题讨论】:

  • 跟那个说再见。切换到 VS2017。
  • 我期待使用 VS2017,但不会再等几周。对有帮助的 cmets 来说太多了。

标签: .net .net-standard


【解决方案1】:

对于 VS2015 在 .csproj 文件的最后,添加:

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

【讨论】:

    【解决方案2】:

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

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

    这对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 2020-12-20
      • 2019-10-25
      • 1970-01-01
      • 2016-06-27
      • 2019-01-03
      • 1970-01-01
      相关资源
      最近更新 更多