【问题标题】:Xamarin Error when upgrading to netstandard2.0升级到 netstandard2.0 时出现 Xamarin 错误
【发布时间】:2018-12-22 05:41:01
【问题描述】:

我正在尝试更新 xamarim 项目以使用 netstandard2.0。但这会产生以下错误:

严重性代码描述项目文件行抑制状态 错误您的项目未引用“.NETPlatform,Version=v5.0”框架。在 project.json 的“frameworks”部分添加对“.NETPlatform,Version=v5.0”的引用,然后重新运行 NuGet 还原。

这是我的 project.json:

{
  "dependencies": {
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "2.0.3",
    "Newtonsoft.Json": "11.0.2",
    "System.Reactive.Linq": "4.0.0"
  },
  "frameworks": {
    "netstandard2.0": {}
  },
  "supports": {}
}

【问题讨论】:

  • 您需要更大的升级。现在没有人应该使用project.json,请迁移到包参考。

标签: .net xamarin xamarin.forms compiler-errors visual-studio-2017


【解决方案1】:

切换到.NET Standard 2.0 非常简单。有很多关于它的文章,从官方文档到 youtube 视频。以下是有关如何执行此操作的几个简单步骤的简短摘要:

  1. 卸载您的 PCL 项目(右键单击 -> 卸载),然后开始编辑 它(右键 -> 点击编辑)
  2. 删除 csproj 中的所有内容并插入:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <!--<PackageReference Include="" Version=""/>-->
  </ItemGroup>

</Project>
  1. 添加回 NuGet(只需打开 packages.config,然后添加上面的包引用,或通过 NuGet 包管理器。
  2. 删除 AssemblyInfo.cs(现在在 csproj 中)和 packages.config(也在 csproj 中通过 PackageReference)

来源:https://gist.github.com/yuv4ik/063a35fe3986e62d69aee2f0ed0607bf

或者,如果您使用 Visual Studio for Mac,您可以使用 Mutatio 一个 VS 扩展来自动化该过程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    • 2015-05-24
    • 1970-01-01
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多