gpt4 book ai didi

.net - 如何在 Rider 中同时加载 5.0 和 4.7.2 项目?

转载 作者:行者123 更新时间:2023-12-04 18:38:59 26 4
gpt4 key购买 nike

我有一个包含 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)之间进行选择。此设置会影响解决方案中的所有项目。
Use MSBuild version: 15.0 or 16.0
如果我选择 15.0 (Mono) 那么 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.0v4.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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com