Revert "Refactor Microsoft.IO usage"#13194
Merged
YuliiaKovalova merged 1 commit intomainfrom Feb 4, 2026
Merged
Conversation
This reverts commit 6b7a28c.
JanProvaznik
approved these changes
Feb 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Reverts prior refactoring of Microsoft.IO usage due to a Visual Studio regression (#13062).
Changes:
- Restores conditional
Microsoft.IOimports/usages across MSBuild components (often switching conditionals toNETFRAMEWORK). - Adjusts
System.IO/Microsoft.IOusing directives and aliases in product code and unit tests. - Tweaks a traversal-project filename check to use
Microsoft.IO.PathunderNET471_OR_GREATER.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tasks/XamlTaskFactory/CommandLineGenerator.cs | Adds Microsoft.IO import for NETFRAMEWORK. |
| src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs | Reorders System.IO and adds a NETFRAMEWORK-only Microsoft.IO alias. |
| src/Shared/TaskFactoryUtilities.cs | Switches System.IO vs Microsoft.IO selection to NETFRAMEWORK. |
| src/Shared/FileSystem/WindowsFileSystem.cs | Switches Microsoft.IO.File.Exists guard to NETFRAMEWORK. |
| src/Shared/FileMatcher.cs | Switches System.IO vs Microsoft.IO selection to NETFRAMEWORK-based. |
| src/MSBuild/XMake.cs | Switches Microsoft.IO alias block guard to NETFRAMEWORK. |
| src/MSBuild.UnitTests/MSBuildServer_Tests.cs | Adds NETFRAMEWORK conditional Microsoft.IO import and Path aliasing. |
| src/Framework/PathHelpers/AbsolutePath.cs | Switches System.IO vs Microsoft.IO selection to NETFRAMEWORK. |
| src/Build/Utilities/Utilities.cs | Switches System.IO vs Microsoft.IO selection based on NET. |
| src/Build/Logging/TerminalLogger/TerminalLogger.cs | Switches System.IO vs Microsoft.IO selection to NETFRAMEWORK. |
| src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs | Switches System.IO vs Microsoft.IO selection to NETFRAMEWORK. |
| src/Build/Evaluation/Expander/ArgumentParser.cs | Adds NETFRAMEWORK-only Microsoft.IO import. |
| src/Build/Evaluation/Expander.cs | Switches System.IO vs Microsoft.IO selection based on NET. |
| src/Build/BuildCheck/Checks/ExecCliBuildCheck.cs | Adjusts System.IO import conditional around FEATURE_MSIOREDIST. |
| src/Build/BuildCheck/Checks/DoubleWritesCheck.cs | Adjusts System.IO import conditional around FEATURE_MSIOREDIST. |
| src/Build/BackEnd/Shared/BuildRequestConfiguration.cs | Uses Microsoft.IO.Path span API under NET471_OR_GREATER for traversal detection. |
Comments suppressed due to low confidence (2)
src/MSBuild/XMake.cs:57
Microsoft.IOis only referenced whenFeatureMSIORedistis enabled (viaFEATURE_MSIOREDISTand conditionalPackageReference). Guard theseMicrosoft.IOusing-aliases with#if FEATURE_MSIOREDIST(and fall back toSystem.IO) rather than#if NETFRAMEWORK, otherwise .NET Framework builds withDotNetBuildSourceOnly=truewill fail to compile due to missingMicrosoft.IO.Redistreference.
#if NETFRAMEWORK
// Use I/O operations from Microsoft.IO.Redist which is generally higher perf
// and also works around https://github.com/dotnet/msbuild/issues/10540.
// Unnecessary on .NET 6+ because the perf improvements are in-box there.
using Microsoft.IO;
using Directory = Microsoft.IO.Directory;
using File = Microsoft.IO.File;
using FileInfo = Microsoft.IO.FileInfo;
using Path = Microsoft.IO.Path;
#endif
src/Shared/FileSystem/WindowsFileSystem.cs:72
- The
#if NETFRAMEWORKbranch calls intoMicrosoft.IO.File, butMicrosoft.IO.Redistis only referenced whenFEATURE_MSIOREDISTis enabled. This should be conditioned onFEATURE_MSIOREDIST(or ensure the package is always referenced for this build) to avoid compile-time breaks when building .NET Framework without the redist package.
#if NETFRAMEWORK
return Microsoft.IO.File.Exists(path);
#else
return File.Exists(path);
#endif
JanProvaznik
pushed a commit
to JanProvaznik/msbuild
that referenced
this pull request
Feb 25, 2026
Reverts dotnet#13062 It causes regression in VS, see https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2695509 for details. CC: @AR-May
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #13062
It causes regression in VS, see https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2695509 for details.
CC: @AR-May