.net - 升级到 netstandard2.0 时出现 Xamarin 错误
问题描述
我正在尝试更新一个 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": {}
}
解决方案
切换到.NET Standard 2.0
可以非常简单。有很多关于它的文章,从官方文档到 youtube 视频。以下是有关如何执行此操作的几个简单步骤的简短摘要:
- 卸载您的 PCL 项目(右键单击 -> 卸载),然后开始编辑它(右键 -> 单击编辑)
- 删除 csproj 中的所有内容并插入:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!--<PackageReference Include="" Version=""/>-->
</ItemGroup>
</Project>
- 添加回 NuGet(只需打开 packages.config,然后添加上面的包引用,或通过 NuGet 包管理器。
- 删除 AssemblyInfo.cs(现在在 csproj 中)和 packages.config(也在 csproj 中通过 PackageReference)
来源:https
://gist.github.com/yuv4ik/063a35fe3986e62d69aee2f0ed0607bf
或者,如果您使用 Visual Studio for Mac,您可以使用Mutatio一个 VS 扩展来自动化该过程。
推荐阅读
- symfony - easyadmin 实体字段的动态自定义选择
- python - 旋转图像后更新 cv::rect
- javascript - JavaScript GetElementById 为 Null 但元素有值
- oracle - 多对多关系表不工作无法从中删除值
- r - R无法使用Rcpp输入引号
- html - chrome 不支持 application/rtf 类型
- asp.net-mvc - 带有布局页面的部分视图加载
- python - Fargate,Lambda,另一种选择?我将什么用于自定义 python 作业?
- xml - SOAPUI SOAP 模拟错误:前缀不能以 XML 开头:XMLSchema-instance
- oauth - 如何使用 dotnetify 手动授权 IdentityServer4 隐式授权类型?