runtime: Shared framework is missing correct RID fallback chain for manjaro

Describe the bug

A embedded systems project that I am working on uses a C# program as a serial loader to send data to an Arduino Nano. I have installed dotnet and adding the System.Io.Ports package on the host machine. When trying to run the project, I get an error saying that System.Io.Ports is only available on windows. This same code and installation process works on Ubuntu 18.04, the latest version of Arch Linux, and Mac without issue.

To Reproduce

Exceptions (if any)

Unhandled exception. System.PlatformNotSupportedException: System.IO.Ports is currently only supported on Windows.
   at System.IO.Ports.SerialPort..ctor()
   at SerialComPort.Main(String[] args) in /home/jason/collective/soen-422/SOEN422-PROJ/vm/task5/Lecture8_SerialLoader.cs:line 121

Further technical details

Project is built and run through the CLI using the command sudo dotnet run <file> dotnet --info on the Manjaro system

.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     manjaro
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

output of dotnet list package :

Project 'csloader' has the following package references
   [net6.0]: 
   Top-level Package      Requested   Resolved
   > System.IO.Ports      6.0.0       6.0.0   

Here is dotnet --info on the Arch and Ubuntu systems where the System.Io.Serial does work on this project:

.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /snap/dotnet-sdk/147/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [/snap/dotnet-sdk/147/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/snap/dotnet-sdk/147/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/snap/dotnet-sdk/147/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     arch
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 45 (23 by maintainers)

Most upvoted comments

We don’t plan to make any changes for this area for .NET 7. For .NET 8, we’re investigating https://github.com/dotnet/runtime/issues/59803, which may address this scenario directly, or cause us to take a different change for this.

In the meantime I see two potential solutions:

  1. Use the Microsoft-provided zip files for portable linux-x64 (i.e. from https://dot.net/download)
  2. Contact the maintainer of the dotnet package for the distro and have them manually fix up the runtime.json file to contain all the appropriate fallbacks

I decided to try out the AUR packages as well, as they seem to work better than the official ones by many reports. I installed dotnet-sdk-bin and aspnet-targeting-pack-bin and repeated the steps described above.

The results are in this gist.

Some observations:

  • there are many more fallback chains but none of them contain manjaro
  • HostRID is still manjaro-x64 and fall back to base HostRID linux-x64
  • working trace contains line “Chose unix, so removing rid (win) specific assets for package System.IO.Ports/6.0.0 and asset type runtime” which can’t be found anywhere in the failing one
 RID:         arch-x64

This should load net6.0-unix implementation in the runtimes/unix/lib/net6.0 folder per https://github.com/dotnet/runtime/commit/00d8f8e378be27edeb37a4f5655ccd831f1cf891#diff-896c6652ae24cab2b91d7d5ab1696fced448d15514a344b7ea9d08552275d817R286

But instead is loading the platform-agnostic implementation (net6.0), which (BUG) should update its resource string. It could be caused by how your referencing the Ports (make sure to use the package) or loading it (make sure its listed in your project’s deps file).

Can you run just the output of the project, with host tracing enabled? That should indicate which RID the host is using and what assemblies it’s considering when you load System.IO.Ports.dll.