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

How to detect linux distribution name/version when in WSL? #30213

Closed
tlmii opened this issue Jul 10, 2019 · 4 comments
Closed

How to detect linux distribution name/version when in WSL? #30213

tlmii opened this issue Jul 10, 2019 · 4 comments

Comments

@tlmii
Copy link
Member

tlmii commented Jul 10, 2019

Over at https://github.com/aspnet/HttpRepl, there's some code that does detection of linux distro in order to decide if some STTY settings need to be changed.

This works fine on normal installs of Ubuntu, but in Ubuntu 18.04 on WSL2, the call to RuntimeInformation.OSDescription returns the following:

"Linux 4.19.43-microsoft-standard dotnet/corefx#1 SMP Mon May 20 19:35:22 UTC 2019"

Is there a way to get the distribution name/version from .NET Core in this scenario? Or should we resort to something like piping the output of lsb_release -a?

@danmoseley
Copy link
Member

danmoseley commented Jul 10, 2019

Looks like you need to add a package reference to Microsoft.DotNet.PlatformAbstractions then you can get it from Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem and Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion

Code is here https://github.com/dotnet/core-setup/blob/master/src/managed/Microsoft.DotNet.PlatformAbstractions/RuntimeEnvironment.cs

On my WSL it returns "ubuntu" and "18.04"

We would like to expose this information in the bass class libraries but that work has been pushed out of 3.0 for now. That is tracked already in https://github.com/dotnet/corefx/issues/31002

@danmoseley
Copy link
Member

If you don't want the package reference (which is great, we would rather deprecate that package long term) looks like you can copy code. See LoadDistroInfo in that repo.

@tlmii
Copy link
Member Author

tlmii commented Jul 10, 2019

Perfect. Thanks Dan. I'll talk it over with the team and make a call on which way to go. Good to know you'd like to deprecate, as that'll probably impact our decision.

@danmoseley
Copy link
Member

Tracked by other issue...

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 3.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants