-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Work around known issues in "Ubuntu on Windows" #11574
Changes from all commits
28979b1
cb538ba
680824e
6d8297a
a0639a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,32 @@ public static class PlatformDetection | |
|
||
public static int WindowsVersion { get; } = GetWindowsVersion(); | ||
|
||
private static Lazy<bool> m_isWindowsSubsystemForLinux = new Lazy<bool>(GetIsWindowsSubsystemForLinux); | ||
|
||
public static bool IsWindowsSubsystemForLinux => m_isWindowsSubsystemForLinux.Value; | ||
public static bool IsNotWindowsSubsystemForLinux => !IsWindowsSubsystemForLinux; | ||
|
||
private static bool GetIsWindowsSubsystemForLinux() | ||
{ | ||
// https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364 | ||
|
||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
const string versionFile = "/proc/version"; | ||
if (File.Exists(versionFile)) | ||
{ | ||
var s = File.ReadAllText(versionFile); | ||
|
||
if (s.Contains("Microsoft") || s.Contains("WSL")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the chance that some Linux distribution will contain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure...WSL sounds like an uncommon sequence of characters to me, but that's hard to predict. We could maybe do a little more rigorous parsing here, but I'm not sure it's worth the additional risk of getting things wrong. The worst-case scenario is that we stop running some tests on a distro where they should run, but at least there's a chance that whoever is porting to that distro will notice, since xunit prints messages about tests that were skipped conditionally. |
||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static bool IsDebian8 { get; } = IsDistroAndVersion("debian", "8"); | ||
public static bool IsUbuntu1510 { get; } = IsDistroAndVersion("ubuntu", "15.10"); | ||
public static bool IsUbuntu1604 { get; } = IsDistroAndVersion("ubuntu", "16.04"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out? If it's necessary, could you add a comment explaining and linking to whatever the associated issue # is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this; I thought I'd already added a comment here. Fixed.