diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs index 8061eb6bd16c44..c3fea537d8c349 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/FileStreamConformanceTests.Windows.cs @@ -85,15 +85,23 @@ public class UncFilePathFileStreamStandaloneConformanceTests : UnbufferedAsyncFi private static Lazy _canShareFiles = new Lazy(() => { - if (!PlatformDetection.IsWindowsAndElevated || PlatformDetection.IsWindowsNanoServer) + if (!PlatformDetection.IsWindowsAndElevated) { return false; } - // the "Server Service" allows for file sharing. It can be disabled on some of our CI machines. - using (ServiceController sharingService = new ServiceController("Server")) + try + { + // the "Server Service" allows for file sharing. It can be disabled on some machines. + using (ServiceController sharingService = new ServiceController("Server")) + { + return sharingService.Status == ServiceControllerStatus.Running; + } + } + catch (InvalidOperationException) { - return sharingService.Status == ServiceControllerStatus.Running; + // The service is not installed. + return false; } }); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 7e2fcb98bc99a1..bd4f28434bc479 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -485,8 +485,6 @@ - -