diff --git a/src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj b/src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj
index 378c5127883..7d03aef7611 100644
--- a/src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj
+++ b/src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj
@@ -1,6 +1,6 @@
-
+
diff --git a/src/Build.OM.UnitTests/MockManagedFileSystemChangeWavesExtension.cs b/src/Build.OM.UnitTests/MockManagedFileSystemChangeWavesExtension.cs
new file mode 100644
index 00000000000..ded6bcd47bc
--- /dev/null
+++ b/src/Build.OM.UnitTests/MockManagedFileSystemChangeWavesExtension.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// This file is a workaround from PR https://github.com/dotnet/msbuild/pull/6771.
+// We need to avoid using ChangeWaves.cs in Microsoft.Build.Engine.OM.UnitTests.
+// It mocks ManagedFileSystemChangeWavesExtension.cs.
+// We are mocking the call ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0) as true.
+// After deleting changewave 17_0 delete this file as well.
+
+#if FEATURE_MSIOREDIST
+namespace Microsoft.Build.Shared.FileSystem
+{
+ ///
+ /// Implementation of file system operations directly over the dot net managed layer
+ ///
+
+ internal partial class ManagedFileSystem : IFileSystem
+ {
+ private bool ShouldUseMicrosoftIO = true;
+ }
+}
+#endif
diff --git a/src/Shared/FileSystem/ManagedFileSystem.cs b/src/Shared/FileSystem/ManagedFileSystem.cs
index 69ca0f81e05..4a60f08884a 100644
--- a/src/Shared/FileSystem/ManagedFileSystem.cs
+++ b/src/Shared/FileSystem/ManagedFileSystem.cs
@@ -11,7 +11,7 @@ namespace Microsoft.Build.Shared.FileSystem
///
/// Implementation of file system operations directly over the dot net managed layer
///
- internal class ManagedFileSystem : IFileSystem
+ internal partial class ManagedFileSystem : IFileSystem
{
private static readonly ManagedFileSystem Instance = new ManagedFileSystem();
@@ -69,7 +69,7 @@ Microsoft.IO.SearchOption searchOption
public virtual IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
- return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
+ return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFiles(path, searchPattern, searchOption),
path,
@@ -85,7 +85,7 @@ public virtual IEnumerable EnumerateFiles(string path, string searchPatt
public virtual IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
- return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
+ return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateDirectories(path, searchPattern, searchOption),
path,
@@ -101,7 +101,7 @@ public virtual IEnumerable EnumerateDirectories(string path, string sear
public virtual IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
{
#if FEATURE_MSIOREDIST
- return ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0)
+ return ShouldUseMicrosoftIO
? HandleFileLoadException(
(path, searchPattern, searchOption) => Microsoft.IO.Directory.EnumerateFileSystemEntries(path, searchPattern, searchOption),
path,
diff --git a/src/Shared/FileSystemSources.proj b/src/Shared/FileSystemSources.proj
index f86f3cfbd1c..a86707414c4 100644
--- a/src/Shared/FileSystemSources.proj
+++ b/src/Shared/FileSystemSources.proj
@@ -1,7 +1,9 @@
+
+
-
- FileSystem\%(Filename).cs
+
+ FileSystem\ManagedFileSystemChangeWavesExtension.cs
-
\ No newline at end of file
+
diff --git a/src/Shared/FileSystemSourcesBase.proj b/src/Shared/FileSystemSourcesBase.proj
new file mode 100644
index 00000000000..960fbe50b44
--- /dev/null
+++ b/src/Shared/FileSystemSourcesBase.proj
@@ -0,0 +1,7 @@
+
+
+
+ FileSystem\%(Filename).cs
+
+
+
diff --git a/src/Shared/ManagedFileSystemChangeWavesExtension.cs b/src/Shared/ManagedFileSystemChangeWavesExtension.cs
new file mode 100644
index 00000000000..279d2e0a1b0
--- /dev/null
+++ b/src/Shared/ManagedFileSystemChangeWavesExtension.cs
@@ -0,0 +1,23 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// This file is a workaround from PR https://github.com/dotnet/msbuild/pull/6771.
+// We need to avoid using ChangeWaves.cs in Microsoft.Build.Engine.OM.UnitTests.
+// Usage of ChangeWaves class in ManagedFileSystem is done in this separate file.
+// In Microsoft.Build.Engine.OM.UnitTests this part is mocked (see MockManagedFileSystemChangeWavesExtension.cs).
+// After deleting changewave 17_0 delete this file as well.
+
+#if FEATURE_MSIOREDIST
+using Microsoft.Build.Utilities;
+
+namespace Microsoft.Build.Shared.FileSystem
+{
+ ///
+ /// Implementation of file system operations directly over the dot net managed layer
+ ///
+ internal partial class ManagedFileSystem : IFileSystem
+ {
+ private bool ShouldUseMicrosoftIO = ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_0);
+ }
+}
+#endif