I am having issues running apps that target anything lower than .net6.0. I thought that the .NET SDK allows to run projects that target older .NET versions as well. Here's a quote from MSDN:
A given SDK supports a fixed set of frameworks, capped to the target framework of the runtime it ships with. For example, the .NET 5 SDK includes the .NET 5 runtime, which is an implementation of the net5.0 target framework. The .NET 5 SDK supports netcoreapp2.0, netcoreapp2.1, netcoreapp3.0, and so on, but not net6.0 (or higher). You install the .NET 6 SDK to build for net6.0.
My understanding of it is that .NET 6.0 SDK should allow me to run older projects, like the one targeting netcoreapp3.1.
On the same page, I see another statement, which contradicts the one I pasted above:
3.0 is specified. No 3.x versions are installed. 5.0.0 is the highest runtime installed. An error message is displayed.
Here it says that newer .NET SDK version will not run an older project.
That's what I'm experiencing as well. My project is as follows:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
When I dotnet run it I get:
A fatal error occurred. The required library libhostfxr.dylib could not be found. If this is a self-contained application, that library should exist in [/Users/me/tmp/netcore3app/bin/Debug/netcoreapp3.1/]. If this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location]. The .NET Core runtime can be found at: - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.10.17-x64
I also tried to follow the roll-forward behavior control instructions and running the app with dotnet run --roll-forward LatestMajor, but that didn't change anything. The same error is thrown.
Is there any way to run projects older than .NET 6 on M1 macs? Is such a scenario even supported?