Skip to content

Revert "Refactor Microsoft.IO usage"#13194

Merged
YuliiaKovalova merged 1 commit intomainfrom
revert-13062-refactor-redist-usage
Feb 4, 2026
Merged

Revert "Refactor Microsoft.IO usage"#13194
YuliiaKovalova merged 1 commit intomainfrom
revert-13062-refactor-redist-usage

Conversation

@YuliiaKovalova
Copy link
Copy Markdown
Member

Reverts #13062

It causes regression in VS, see https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2695509 for details.
CC: @AR-May

@YuliiaKovalova YuliiaKovalova marked this pull request as ready for review February 4, 2026 12:24
Copilot AI review requested due to automatic review settings February 4, 2026 12:24
@YuliiaKovalova YuliiaKovalova self-assigned this Feb 4, 2026
@YuliiaKovalova YuliiaKovalova enabled auto-merge (squash) February 4, 2026 12:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reverts prior refactoring of Microsoft.IO usage due to a Visual Studio regression (#13062).

Changes:

  • Restores conditional Microsoft.IO imports/usages across MSBuild components (often switching conditionals to NETFRAMEWORK).
  • Adjusts System.IO / Microsoft.IO using directives and aliases in product code and unit tests.
  • Tweaks a traversal-project filename check to use Microsoft.IO.Path under NET471_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.IO is only referenced when FeatureMSIORedist is enabled (via FEATURE_MSIOREDIST and conditional PackageReference). Guard these Microsoft.IO using-aliases with #if FEATURE_MSIOREDIST (and fall back to System.IO) rather than #if NETFRAMEWORK, otherwise .NET Framework builds with DotNetBuildSourceOnly=true will fail to compile due to missing Microsoft.IO.Redist reference.
#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 NETFRAMEWORK branch calls into Microsoft.IO.File, but Microsoft.IO.Redist is only referenced when FEATURE_MSIOREDIST is enabled. This should be conditioned on FEATURE_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

@YuliiaKovalova YuliiaKovalova merged commit 7e0e757 into main Feb 4, 2026
15 checks passed
@YuliiaKovalova YuliiaKovalova deleted the revert-13062-refactor-redist-usage branch February 4, 2026 15:15
JanProvaznik pushed a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants