Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide APIs to determine OS, Distribution, Version, Bitness and other useful Info #18993

Closed
richlander opened this issue Oct 17, 2016 · 13 comments
Assignees
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Runtime help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@richlander
Copy link
Member

I would like to be able to get this information from System.Environment.

I've been recently playing with the lsb_release command. I should be able to get most of this same information from System.Environment.

I saw some earlier discussions on some APIs leading to bad practices (for example, checking feature availability based on versions). All true, but I don't think we should use those bad practices as a reason not to make APIs available. That's the role of documentation and samples, IMO.

Related: https://github.com/dotnet/corefx/issues/1017

@danmoseley
Copy link
Member

On Environment we now have OSVersion, Is64Bit, Is64BitProcess

@richlander
Copy link
Member Author

Which version of the product is that for? 1.2?

@danmoseley
Copy link
Member

Yes

@mellinoe
Copy link
Contributor

.NET Core 1.0 actually has more of this information, via System.Runtime.InteropServices.RuntimeInformation. We should probably treat the stuff in Environment as legacy, anyways, not as a future-proof way to query information about the system. Is there something else you need than is exposed by RuntimeInformation?

@terrajobst
Copy link
Member

System.Environment doesn't expose this in .NET Core 1.0 as we were asked to remove versioning APIs due to compat concerns. However, they come back in vNext as part of .NET Standard 2.0.

For 1.0, the APIs that @mellinoe pointed you to should address these concerns partially. Most of the APIs return strings, but depending on your use case this might work.

@Petermarcu
Copy link
Member

Ok, so is this already addressed then in 1.2 with .NET Standard 2.0 support?

@mellinoe
Copy link
Contributor

@Petermarcu RuntimeInformation (in .NET Core 1.0) offers quite a bit of this information. The new stuff we are adding back in 2.0 has some related things, but nothing that we don't already expose in RuntimeInformation.

@richlander mentioned lsb_release, which prints out a couple more things that we don't expose anywhere (in 1.0 or 2.0).

Description:    Ubuntu 16.04 LTS
Codename:       xenial

RuntimeInformation.OSDescription gives the same information as uname -a (by design):

Linux 4.4.0-42-generic dotnet/runtime#13867-Ubuntu SMP Fri Oct 7 00:00:00 UTC 2016

So nothing about "16.04 LTS", or "xenial".

@Petermarcu
Copy link
Member

Petermarcu commented Oct 17, 2016

So @richlander, are you looking to have Description and Codename exposed?

@weshaggard
Copy link
Member

@richlander are you wanting this information just as a description string or in some other form? Do you expect people to make runtime decisions based on it?

If we want more APIs we need to put someone on this and write a design proposal for the scenarios we want to support. I also agree with @mellinoe that we should be preferring RuntimeInformation for new APIs over putting them on Environment because the Environment class doesn't have the agility we need in order to support the ever changing number of runtimes/os/etc we want to run on.

@richlander
Copy link
Member Author

/cc @leecow

@Priya91
Copy link
Contributor

Priya91 commented Nov 15, 2016

Since you mention lsb_release for retrieving this information, not all Linux distributions are LSB compliant. I had considered using this function while implementing RuntimeInformation.OSVersion, and because there is no guarantee on this being available on all distros, POSIX compliant uname was chosen.

I may be wrong, but I couldn't find a reliable way to get distro version and other distro specific info through a single API that is universal across Linux. When such standard is not provided by the OS, I am not sure how a reliable solution can be provided through .NET.

@AlexGhiondea
Copy link
Contributor

Regardless of how we implement this, @richlander do we want to have the API?

If we do, then we are going to need a formal API proposal for them.

@leecow leecow self-assigned this Jan 27, 2017
@richlander
Copy link
Member Author

Looks like @leecow has a proposal for this, which is great, with dotnet/corefx#16629.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Runtime help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

No branches or pull requests

10 participants