From 620956fe9fd44cbd8a0fb1d7588aca0c4a21603f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:29:28 +0000 Subject: [PATCH 1/4] Initial plan From 0f362f45af6cf58fd169620a7509d120743f9f7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:36:07 +0000 Subject: [PATCH 2/4] Fix dump path with spaces by quoting the path Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com> --- .../DiagnosticsClient/DiagnosticsClient.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs index dfd1c7f497..85e285ce90 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs @@ -698,7 +698,9 @@ private static IpcMessage CreateWriteDumpMessage(DumpType dumpType, string dumpP throw new ArgumentNullException($"{nameof(dumpPath)} required"); } - byte[] payload = SerializePayload(dumpPath, (uint)dumpType, logDumpGeneration); + // Quote the path to handle spaces correctly in createdump + string quotedPath = $"\"{dumpPath}\""; + byte[] payload = SerializePayload(quotedPath, (uint)dumpType, logDumpGeneration); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump, payload); } @@ -709,7 +711,9 @@ private static IpcMessage CreateWriteDumpMessage(DumpCommandId command, DumpType throw new ArgumentNullException($"{nameof(dumpPath)} required"); } - byte[] payload = SerializePayload(dumpPath, (uint)dumpType, (uint)flags); + // Quote the path to handle spaces correctly in createdump + string quotedPath = $"\"{dumpPath}\""; + byte[] payload = SerializePayload(quotedPath, (uint)dumpType, (uint)flags); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)command, payload); } From c9e0f7752aa8a743d13bc38dfcedaa2f125df1a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:37:44 +0000 Subject: [PATCH 3/4] Improve fix to avoid double-quoting already quoted paths Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com> --- .../DiagnosticsClient/DiagnosticsClient.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs index 85e285ce90..30925a0a59 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs @@ -699,7 +699,8 @@ private static IpcMessage CreateWriteDumpMessage(DumpType dumpType, string dumpP } // Quote the path to handle spaces correctly in createdump - string quotedPath = $"\"{dumpPath}\""; + // Only add quotes if the path is not already quoted + string quotedPath = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; byte[] payload = SerializePayload(quotedPath, (uint)dumpType, logDumpGeneration); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump, payload); } @@ -712,7 +713,8 @@ private static IpcMessage CreateWriteDumpMessage(DumpCommandId command, DumpType } // Quote the path to handle spaces correctly in createdump - string quotedPath = $"\"{dumpPath}\""; + // Only add quotes if the path is not already quoted + string quotedPath = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; byte[] payload = SerializePayload(quotedPath, (uint)dumpType, (uint)flags); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)command, payload); } From 51601ce4e3cfbaa4e442d7689bed00e244d8dbe5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Oct 2025 01:19:41 +0000 Subject: [PATCH 4/4] Restrict path quoting to Windows only Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com> --- .../DiagnosticsClient/DiagnosticsClient.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs index 30925a0a59..d1ce07beed 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs @@ -698,10 +698,15 @@ private static IpcMessage CreateWriteDumpMessage(DumpType dumpType, string dumpP throw new ArgumentNullException($"{nameof(dumpPath)} required"); } - // Quote the path to handle spaces correctly in createdump + // Quote the path to handle spaces correctly in createdump on Windows only // Only add quotes if the path is not already quoted - string quotedPath = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; - byte[] payload = SerializePayload(quotedPath, (uint)dumpType, logDumpGeneration); + // This is only needed on Windows where the runtime builds the command line for createdump + string pathToUse = dumpPath; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + pathToUse = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; + } + byte[] payload = SerializePayload(pathToUse, (uint)dumpType, logDumpGeneration); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump, payload); } @@ -712,10 +717,15 @@ private static IpcMessage CreateWriteDumpMessage(DumpCommandId command, DumpType throw new ArgumentNullException($"{nameof(dumpPath)} required"); } - // Quote the path to handle spaces correctly in createdump + // Quote the path to handle spaces correctly in createdump on Windows only // Only add quotes if the path is not already quoted - string quotedPath = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; - byte[] payload = SerializePayload(quotedPath, (uint)dumpType, (uint)flags); + // This is only needed on Windows where the runtime builds the command line for createdump + string pathToUse = dumpPath; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + pathToUse = dumpPath.StartsWith("\"") && dumpPath.EndsWith("\"") ? dumpPath : $"\"{dumpPath}\""; + } + byte[] payload = SerializePayload(pathToUse, (uint)dumpType, (uint)flags); return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)command, payload); }