diff --git a/src/Build/Logging/ProfilerLogger.cs b/src/Build/Logging/ProfilerLogger.cs
index 77c521d5452..b80dcf8cf0e 100644
--- a/src/Build/Logging/ProfilerLogger.cs
+++ b/src/Build/Logging/ProfilerLogger.cs
@@ -297,19 +297,12 @@ private void GenerateProfilerReport()
Console.WriteLine(ResourceUtilities.GetResourceString("WritingProfilerReportDone"));
}
- catch (DirectoryNotFoundException ex)
- {
- Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
- }
- catch (IOException ex)
- {
- Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
- }
- catch (UnauthorizedAccessException ex)
- {
- Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
- }
- catch (SecurityException ex)
+ catch (Exception ex) when (ex is
+ DirectoryNotFoundException or
+ IOException or
+ UnauthorizedAccessException or
+ SecurityException or
+ ArgumentException)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("ErrorWritingProfilerReport", ex.Message));
}
diff --git a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
index 6ffae8dfb52..47e9361022d 100644
--- a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
+++ b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs
@@ -1531,25 +1531,6 @@ public void ProcessInvalidTargetSwitch()
#endif
}
- ///
- /// Verifies that when the /profileevaluation switch is used with invalid filenames an error is shown.
- ///
- [MemberData(nameof(GetInvalidFilenames))]
- [WindowsFullFrameworkOnlyTheory(additionalMessage: ".NET Core 2.1+ no longer validates paths: https://github.com/dotnet/corefx/issues/27779#issuecomment-371253486.")]
- public void ProcessProfileEvaluationInvalidFilename(string filename)
- {
- bool enableProfiler = false;
- Should.Throw(
- () => MSBuildApp.ProcessProfileEvaluationSwitch(new[] { filename }, new List(), out enableProfiler),
- typeof(CommandLineSwitchException));
- }
-
- public static IEnumerable