Avoiding non-crossplatform dependencies in .Net Standard

Viewed 85

I'm porting the existing library from .Net Framework 4.7.2 to .Net Standard 2.0 to make it cross-platform but still retain compatibility with .Net Framework apps.

I do not understand how to avoid non-cross-platform dependencies.

My library uses dynamic types and Settings.Designer.cs.

To support it in .Net Standard, I have to add a reference to Microsoft.CSharp and System.Configuration.ConfigurationManager NuGet packages, which in turn adds dependencies to some other packages like System.Security.Principal.Windows, even though I don't use any security-related code.

The last two are clearly part of Microsoft.Windows.Compatibility package.

NuGet dependencies

  1. How to find out, if these dependencies are cross-platform or not (i.e. part of Windows Platform Extensions)?

When I go to .NET API Browser I see that Microsoft.Csharp is not in .Net Standard 2.0, however it is in .Net Platform Extensions 2.1 and further. Does it mean, that this package is not cross-platform? Are there any other services to check platform support for NuGet packages?

.NEt API results

  1. When I created a simple test app on .Net Core 2.1 that uses my library and published it to a Linux platform with dotnet publish -c Release --self-contained true --runtime linux-x64, the app actually works fine on Linux machine. Does it mean, that my lib is fully cross-platform and I can safely use it in production, or I may still encounter System.PlatformNotSupportedException on Linux in the future?
0 Answers
Related