Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Shared/BuildRequestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public bool IsTraversal
{
if (!_isTraversalProject.HasValue)
{
#if NET471_OR_GREATER
#if FEATURE_MSIOREDIST
if (MemoryExtensions.Equals(Microsoft.IO.Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj".AsSpan(), StringComparison.OrdinalIgnoreCase))
#else
if (MemoryExtensions.Equals(Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj", StringComparison.OrdinalIgnoreCase))
Expand Down
5 changes: 2 additions & 3 deletions src/Build/BuildCheck/Checks/DoubleWritesCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

using System;
using System.Collections.Generic;
#if !FEATURE_MSIOREDIST
using System.IO;
#endif
using System.Linq;
using Microsoft.Build.Shared;
using static Microsoft.Build.Experimental.BuildCheck.TaskInvocationCheckData;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif
Comment on lines 10 to 14
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

FEATURE_MSIOREDIST is disabled for DotNetBuildSourceOnly .NETFramework builds, which means this file will use System.IO.Path. However, later in this file Path.GetFullPath(fileBeingWritten, context.Data.ProjectFileDirectory) is used, and that overload does not exist on .NET Framework's System.IO.Path. Provide a netfx fallback when FEATURE_MSIOREDIST is off (e.g., route through FileUtilities.GetFullPath(..., currentDirectory, ...) or equivalent) so source-only netfx builds compile.

Copilot uses AI. Check for mistakes.

namespace Microsoft.Build.Experimental.BuildCheck.Checks;
Expand Down
5 changes: 2 additions & 3 deletions src/Build/BuildCheck/Checks/ExecCliBuildCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

using System;
using System.Collections.Generic;
#if !FEATURE_MSIOREDIST
using System.IO;
#endif
using Microsoft.Build.Shared;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif

namespace Microsoft.Build.Experimental.BuildCheck.Checks;
Expand Down
9 changes: 5 additions & 4 deletions src/Build/Evaluation/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
#if NET
using System.IO;
#else
using Microsoft.IO;
#endif
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
Expand All @@ -34,6 +30,11 @@
using TaskItem = Microsoft.Build.Execution.ProjectItemInstance.TaskItem;
using TaskItemFactory = Microsoft.Build.Execution.ProjectItemInstance.TaskItem.TaskItemFactory;

#if FEATURE_MSIOREDIST
using Directory = Microsoft.IO.Directory;
using Path = Microsoft.IO.Path;
#endif

#nullable disable

namespace Microsoft.Build.Evaluation
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Evaluation/Expander/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Globalization;

#if NETFRAMEWORK
#if FEATURE_MSIOREDIST
using Microsoft.IO;
#endif

Expand Down
5 changes: 3 additions & 2 deletions src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
using Microsoft.Build.BackEnd.Components.RequestBuilder;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
#if NETFRAMEWORK
using Microsoft.IO;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Logging/TerminalLogger/TerminalLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
using System.Buffers;
#endif

#if NETFRAMEWORK
using Microsoft.IO;
#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif
Comment on lines +19 to 23
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

With DotNetBuildSourceOnly on .NETFramework, FEATURE_MSIOREDIST is not defined so Path resolves to System.IO.Path. This file uses APIs like Path.GetRelativePath(...) (not available on .NET Framework), so the source-only .NETFramework build will fail to compile. Please either guard those API usages with #if FEATURE_MSIOREDIST and provide a fallback (e.g., via existing FileUtilities.MakeRelative), or keep Microsoft.IO.Path available for all .NETFramework builds where these APIs are needed.

Copilot uses AI. Check for mistakes.
Expand Down
11 changes: 6 additions & 5 deletions src/Build/Utilities/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
#if NET
using System.IO;
#else
using Microsoft.IO;
#endif
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand All @@ -22,6 +17,12 @@
using Toolset = Microsoft.Build.Evaluation.Toolset;
using XmlElementWithLocation = Microsoft.Build.Construction.XmlElementWithLocation;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif

#nullable disable

namespace Microsoft.Build.Internal
Expand Down
5 changes: 3 additions & 2 deletions src/Framework/PathHelpers/AbsolutePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
#if NETFRAMEWORK
using Microsoft.IO;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using System.IO;
#endif
Comment on lines +6 to 10
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

When DotNetBuildSourceOnly is true on .NETFramework, FEATURE_MSIOREDIST is not defined and this file will use System.IO.Path. But later, ValidatePath calls Path.IsPathFullyQualified(...) under #if NETFRAMEWORK || NET, which won't compile on .NET Framework without Microsoft.IO.Redist. Narrow the guard to FEATURE_MSIOREDIST || NET (or add a .NET Framework fallback) so source-only netfx builds compile.

Copilot uses AI. Check for mistakes.
Expand Down
7 changes: 1 addition & 6 deletions src/MSBuild.UnitTests/MSBuildServer_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
Expand All @@ -13,15 +14,9 @@
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests;
using Microsoft.Build.UnitTests.Shared;
#if NETFRAMEWORK
using Microsoft.IO;
#else
using System.IO;
#endif
using Shouldly;
using Xunit;
using Xunit.Abstractions;
using Path = System.IO.Path;

namespace Microsoft.Build.Engine.UnitTests
{
Expand Down
3 changes: 1 addition & 2 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@
using SimpleErrorLogger = Microsoft.Build.Logging.SimpleErrorLogger.SimpleErrorLogger;
using TerminalLogger = Microsoft.Build.Logging.TerminalLogger;

#if NETFRAMEWORK
#if FEATURE_MSIOREDIST
// 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;
Expand Down
9 changes: 5 additions & 4 deletions src/Shared/FileMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
#if !NETFRAMEWORK
using System.IO;
using System.Linq;

#if FEATURE_MSIOREDIST
using Path = Microsoft.IO.Path;
#else
using Microsoft.IO;
using System.IO;
#endif
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/FileSystem/WindowsFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override bool DirectoryExists(string path)

public override bool FileExists(string path)
{
#if NETFRAMEWORK
#if FEATURE_MSIOREDIST
return Microsoft.IO.File.Exists(path);
#else
return File.Exists(path);
Expand Down
6 changes: 4 additions & 2 deletions src/Shared/TaskFactoryUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using System.Reflection;
using Microsoft.Build.Shared.FileSystem;
using Microsoft.Build.Framework;
#if NETFRAMEWORK
using Microsoft.IO;

#if FEATURE_MSIOREDIST
using File = Microsoft.IO.File;
using Path = Microsoft.IO.Path;
#else
using System.IO;
Comment on lines +10 to 14
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

FEATURE_MSIOREDIST is not defined for DotNetBuildSourceOnly .NETFramework builds, so this file will fall back to System.IO.Path. However, later in this file you call Path.IsPathFullyQualified(...) under #if NETFRAMEWORK || NET, which will not compile on .NET Framework when Path is System.IO.Path (no IsPathFullyQualified there). Update the conditional compilation around the IsPathFullyQualified usage (or provide a .NET Framework fallback implementation) so source-only .NETFramework builds compile without Microsoft.IO.Redist.

Copilot uses AI. Check for mistakes.
#endif
Expand Down
5 changes: 1 addition & 4 deletions src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests;
using Microsoft.Build.UnitTests.Shared;
using Microsoft.Build.Utilities;
using System.IO;
#if NETFRAMEWORK
using MicrosoftIO = Microsoft.IO;
#endif
using Shouldly;
using VerifyTests;
using VerifyXunit;
Expand Down
4 changes: 0 additions & 4 deletions src/Tasks/XamlTaskFactory/CommandLineGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
using System.Text;
using System.Text.RegularExpressions;

#if NETFRAMEWORK
using Microsoft.IO;
#endif

using Microsoft.Build.Framework;
using Microsoft.Build.Framework.XamlTypes;
using Microsoft.Build.Shared;
Expand Down
Loading