I have a .NET solution containing both net5.0
and v4.7.2
projects. It opens as expected in Visual Studio on Windows. But when I open it in Rider on Ubuntu I get assembly errors from one or the other framework. (Rider 2021.1.3 on Ubuntu 20.04.2 LTS installed from Snap Store.)
I have installed latest Stable Mono per 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)
I have installed latest stable .NET SDK from the Snap store.
$ dotnet --version
5.0.301
In Rider I can choose between MSBuild 15.0 (from /usr/lib/mono) or 16.0 (from /snap/dotnet-sdk). This setting affects all projects in the solution.
If I pick 15.0 (Mono) then net5.0
projects fail (see message below) and v4.7.2
load correctly.
[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)
If I pick 16.0 (SDK) then net5.0
projects load correctly but v4.7.2
fail with:
[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)
How can I resolve this so that net5.0
and v4.7.2
projects in the same solution both load without reference errors in Rider on Ubuntu?
You have to install reference assemblies into .NET project which targets net472
(or any other) full framework. More specifically, this NuGet package:
https://www.nuget.org/packages/Microsoft.NETFramework.ReferenceAssemblies/
For more info you can read one of articles about .net reference assemblies, for example this one: https://andrewlock.net/using-reference-assemblies-to-build-net-framework-libararies-on-linux-without-mono/