Skip to content

Commit 94941d9

Browse files
Merge pull request #10705 from rainersigwald/mio-redist-in-main
Use Microsoft.IO.Redist in XMake.cs
2 parents f3c6b67 + 4fe03ac commit 94941d9

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

src/Build/Logging/ProfilerLogger.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,12 @@ private void GenerateProfilerReport()
297297

298298
Console.WriteLine(ResourceUtilities.GetResourceString("WritingProfilerReportDone"));
299299
}
300-
catch (DirectoryNotFoundException ex)
301-
{
302-
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
303-
}
304-
catch (IOException ex)
305-
{
306-
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
307-
}
308-
catch (UnauthorizedAccessException ex)
309-
{
310-
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
311-
}
312-
catch (SecurityException ex)
300+
catch (Exception ex) when (ex is
301+
DirectoryNotFoundException or
302+
IOException or
303+
UnauthorizedAccessException or
304+
SecurityException or
305+
ArgumentException)
313306
{
314307
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
315308
}

src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,25 +1531,6 @@ public void ProcessInvalidTargetSwitch()
15311531
#endif
15321532
}
15331533

1534-
/// <summary>
1535-
/// Verifies that when the /profileevaluation switch is used with invalid filenames an error is shown.
1536-
/// </summary>
1537-
[MemberData(nameof(GetInvalidFilenames))]
1538-
[WindowsFullFrameworkOnlyTheory(additionalMessage: ".NET Core 2.1+ no longer validates paths: https://github.com/dotnet/corefx/issues/27779#issuecomment-371253486.")]
1539-
public void ProcessProfileEvaluationInvalidFilename(string filename)
1540-
{
1541-
bool enableProfiler = false;
1542-
Should.Throw(
1543-
() => MSBuildApp.ProcessProfileEvaluationSwitch(new[] { filename }, new List<ILogger>(), out enableProfiler),
1544-
typeof(CommandLineSwitchException));
1545-
}
1546-
1547-
public static IEnumerable<object[]> GetInvalidFilenames()
1548-
{
1549-
yield return new object[] { $"a_file_with${Path.GetInvalidFileNameChars().First()}invalid_chars" };
1550-
yield return new object[] { $"C:\\a_path\\with{Path.GetInvalidPathChars().First()}invalid\\chars" };
1551-
}
1552-
15531534
/// <summary>
15541535
/// Verifies that help messages are correctly formed with the right width and leading spaces.
15551536
/// </summary>

src/MSBuild/XMake.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@
4343
using SimpleErrorLogger = Microsoft.Build.Logging.SimpleErrorLogger.SimpleErrorLogger;
4444
using TerminalLogger = Microsoft.Build.Logging.TerminalLogger.TerminalLogger;
4545

46+
#if NETFRAMEWORK
47+
// Use I/O operations from Microsoft.IO.Redist which is generally higher perf
48+
// and also works around https://github.com/dotnet/msbuild/issues/10540.
49+
// Unnecessary on .NET 6+ because the perf improvements are in-box there.
50+
using Microsoft.IO;
51+
using Directory = Microsoft.IO.Directory;
52+
using File = Microsoft.IO.File;
53+
using FileInfo = Microsoft.IO.FileInfo;
54+
using Path = Microsoft.IO.Path;
55+
#endif
56+
4657
#nullable disable
4758

4859
namespace Microsoft.Build.CommandLine

0 commit comments

Comments
 (0)