作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 net5.0
的 .NET 解决方案和 v4.7.2
项目。它在 Windows 上的 Visual Studio 中按预期打开。但是当我在 Ubuntu 上的 Rider 中打开它时,我会从一个或另一个框架中得到装配错误。 (从 Snap Store 安装的 Ubuntu 20.04.2 LTS 上的 Rider 2021.1.3。)
我已根据 https://www.mono-project.com/download/stable/#download-lin-ubuntu 安装了最新的稳定单声道
$ mono --version
Mono JIT compiler version 6.12.0.122 (tarball Mon Feb 22 17:33:28 UTC 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)
我已经从 Snap 商店安装了最新的稳定版 .NET SDK。
$ dotnet --version
5.0.301
在 Rider 中,我可以在 MSBuild 15.0(来自/usr/lib/mono)或 16.0(来自/snap/dotnet-sdk)之间进行选择。此设置会影响解决方案中的所有项目。
net5.0
项目失败(见下面的消息)和
v4.7.2
正确加载。
[MSB3644] The reference assemblies for .NETFramework,Version=v5.0 were not found. To
resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version
or retarget your application. You can download .NET Framework Developer Packs
at https://aka.ms/msbuild/developerpacks at (1193:5)
如果我选择 16.0 (SDK) 那么
net5.0
项目加载正确,但
v4.7.2
失败:
[MSB3644] The reference assemblies for .NETFramework,Version=v4.7.2 were not found.
To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework
version or retarget your application. You can download .NET Framework Developer Packs
at https://aka.ms/msbuild/developerpacks at (1216:5)
我怎样才能解决这个问题,以便
net5.0
和
v4.7.2
同一解决方案中的项目在 Ubuntu 上的 Rider 中加载时都没有引用错误?
最佳答案
您必须将引用程序集安装到以 net472
为目标的 .NET 项目中。 (或任何其他)完整框架。更具体地说,这个 NuGet 包:
https://www.nuget.org/packages/Microsoft.NETFramework.ReferenceAssemblies/
有关更多信息,您可以阅读一篇关于 .net 引用程序集的文章,例如这篇:
https://andrewlock.net/using-reference-assemblies-to-build-net-framework-libararies-on-linux-without-mono/
关于.net - 如何在 Rider 中同时加载 5.0 和 4.7.2 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68182012/
我是一名优秀的程序员,十分优秀!