dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 510 forks source link

Missing implementation of System.OperatingSystem.IsWindows #8347

Closed teobugslayer closed 3 years ago

teobugslayer commented 3 years ago

Hi all,

I am trying to write cross-platform code and my attempt to use IsWindows and IsWindowsVersionAtLeast fails:

  Generating native code
EXEC : warning : Method `[ZX]ZX.ConsoleDisplay.Init(int32,int32)` will always throw because: [TEMPORARY EXCEPTION MESSAGE] MissingMethod: Boolean System.OperatingSystem.IsWindows() [C:\Dev\ZX\ZX\ZX.csproj]
EXEC : warning : Method `[ZX]ZX.Program.ValidateCanRun()` will always throw because: [TEMPORARY EXCEPTION MESSAGE] MissingMethod: Boolean System.OperatingSystem.IsWindowsVersionAtLeast(Int32, Int32, Int32, Int32) [C:\Dev\ZX\ZX\ZX.csproj]

What are my options to rectify the problem?

MichalStrehovsky commented 3 years ago

Number of .NET 5 APIs are not available in CoreRT right now because we stopped synchronizing them with the runtime due to technical difficulties a couple months ago.

This will be resolved once this repo is fully migrated to dotnet/runtimelab (https://github.com/dotnet/runtimelab/issues/4) where the managed APIs are already fully synchronized with the mainstream runtimes. We just don't have official builds and packages yet.

For now you need to stick to .NET 3.1 APIs.

jkotas commented 3 years ago

Fixed in dotnet/runtimelab. Update your nuget feed to the one in https://github.com/dotnet/runtimelab/tree/feature/NativeAOT/samples/HelloWorld