My .NET Core 3.0 app is published for different operating systems, using the commands dotnet publish -r win10-x64
or dotnet publish -r ubuntu.18.04-x64
for example.
During runtime, in my C# code I want to find out the target the app was built for. I do not mean just the general operating system like Windows or Linux (as asked here), but the exact runtime target, like ubuntu-18.04-x64
.
I already found out, that there is a file <AssemblyName>.deps.json
. It contains the property "runtimeTarget": { "name": ".NETCoreApp,Version=v3.0/ubuntu.18.04-x64", ...
, but maybe there is a better way?