From 0ca315758768d2f194e252068a4ea06d4a384b13 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 19:47:45 +0000 Subject: [PATCH 1/4] Initial plan From 089797c9d765b9947af99de74493ccd00eb03186 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 19:57:18 +0000 Subject: [PATCH 2/4] Add Native AOT test with space in path Add a new test case that verifies Native AOT publishing works correctly when the project path contains a space. This test: - Creates a test project with an identifier containing a space ("with space") - Publishes the project with PublishAot=true - Verifies the path actually contains a space - Confirms the native executable is created and runs successfully Co-authored-by: agocke <515774+agocke@users.noreply.github.com> --- .../GivenThatWeWantToPublishAnAotApp.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs index 2f28bcd53135..73d6d9cef0da 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs @@ -77,6 +77,62 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string .And.HaveStdOutContaining("Hello World"); } + [RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")] + [MemberData(nameof(Net7Plus), MemberType = typeof(PublishTestUtils))] + public void NativeAot_app_publishes_with_space_in_path(string targetFramework) + { + if (targetFramework == "net7.0" && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // 7.0 is not supported on Mac + return; + } + + var projectName = "HelloWorldNativeAotApp"; + + var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true); + testProject.RecordProperties("NETCoreSdkPortableRuntimeIdentifier"); + testProject.AdditionalProperties["PublishAot"] = "true"; + // Linux symbol files are embedded and require additional steps to be stripped to a separate file + // assumes /bin (or /usr/bin) are in the PATH + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + testProject.AdditionalProperties["StripSymbols"] = "true"; + } + // Use an identifier with a space to create a path with a space + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: "with space"); + + var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + publishCommand + .Execute($"/p:UseCurrentRuntimeIdentifier=true", "/p:SelfContained=true", "/p:CheckEolTargetFramework=false") + .Should().Pass() + .And.NotHaveStdOutContaining("IL2026") + .And.NotHaveStdErrContaining("NETSDK1179") + .And.NotHaveStdErrContaining("warning") + .And.NotHaveStdOutContaining("warning"); + + var buildProperties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework); + var rid = buildProperties["NETCoreSdkPortableRuntimeIdentifier"]; + var publishDirectory = publishCommand.GetOutputDirectory(targetFramework: targetFramework, runtimeIdentifier: rid).FullName; + var publishedExe = Path.Combine(publishDirectory, $"{testProject.Name}{Constants.ExeSuffix}"); + + // Verify the path contains a space + testAsset.TestRoot.Should().Contain(" ", "Test should run with a space in the path"); + + // The exe should exist and should be native + File.Exists(publishedExe).Should().BeTrue(); + DoSymbolsExist(publishDirectory, testProject.Name).Should().BeTrue($"{publishDirectory} should contain {testProject.Name} symbol"); + IsNativeImage(publishedExe).Should().BeTrue(); + + bool useRuntimePackLayout = targetFramework is not ("net7.0" or "net8.0" or "net9.0"); + + GetKnownILCompilerPackVersion(testAsset, targetFramework, out string expectedVersion); + CheckIlcVersions(testAsset, targetFramework, rid, expectedVersion, useRuntimePackLayout); + + var command = new RunExeCommand(Log, publishedExe) + .Execute().Should().Pass() + .And.HaveStdOutContaining("Hello World"); + } + [RequiresMSBuildVersionTheory("17.12.0")] [MemberData(nameof(Net7Plus), MemberType = typeof(PublishTestUtils))] public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_false(string targetFramework) From 900e4f67e9e8a669f2b65aebbbc3e96dd7bac921 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 20:26:12 +0000 Subject: [PATCH 3/4] Address PR feedback: use CurrentTargetFramework and more contrasting path identifier - Changed from testing all Net7Plus frameworks to only CurrentTargetFramework - Removed unnecessary macOS/net7.0 platform check - Changed identifier from "with space" to "path with spaces" for better contrast Co-authored-by: agocke <515774+agocke@users.noreply.github.com> --- .../GivenThatWeWantToPublishAnAotApp.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs index 73d6d9cef0da..1f05a4532d7c 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs @@ -78,15 +78,9 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string } [RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")] - [MemberData(nameof(Net7Plus), MemberType = typeof(PublishTestUtils))] + [InlineData(ToolsetInfo.CurrentTargetFramework)] public void NativeAot_app_publishes_with_space_in_path(string targetFramework) { - if (targetFramework == "net7.0" && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - // 7.0 is not supported on Mac - return; - } - var projectName = "HelloWorldNativeAotApp"; var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true); @@ -99,7 +93,7 @@ public void NativeAot_app_publishes_with_space_in_path(string targetFramework) testProject.AdditionalProperties["StripSymbols"] = "true"; } // Use an identifier with a space to create a path with a space - var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: "with space"); + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: "path with spaces"); var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); publishCommand From 1bcf1bd003d43dea2225bd8623bb15d22a840392 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 18:43:20 +0000 Subject: [PATCH 4/4] Simplify test: change to Fact and remove unnecessary settings - Changed from RequiresMSBuildVersionTheory with InlineData to Fact - Removed StripSymbols setting (default in .NET 10) - Removed useRuntimePackLayout logic (hardcoded to true) - Set targetFramework directly to CurrentTargetFramework Co-authored-by: agocke <515774+agocke@users.noreply.github.com> --- .../GivenThatWeWantToPublishAnAotApp.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs index 1f05a4532d7c..93689f9ad7e7 100644 --- a/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs +++ b/test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAotApp.cs @@ -77,21 +77,15 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string .And.HaveStdOutContaining("Hello World"); } - [RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")] - [InlineData(ToolsetInfo.CurrentTargetFramework)] - public void NativeAot_app_publishes_with_space_in_path(string targetFramework) + [Fact(Skip = "https://github.com/dotnet/sdk/issues/46006")] + public void NativeAot_app_publishes_with_space_in_path() { + var targetFramework = ToolsetInfo.CurrentTargetFramework; var projectName = "HelloWorldNativeAotApp"; var testProject = CreateHelloWorldTestProject(targetFramework, projectName, true); testProject.RecordProperties("NETCoreSdkPortableRuntimeIdentifier"); testProject.AdditionalProperties["PublishAot"] = "true"; - // Linux symbol files are embedded and require additional steps to be stripped to a separate file - // assumes /bin (or /usr/bin) are in the PATH - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - testProject.AdditionalProperties["StripSymbols"] = "true"; - } // Use an identifier with a space to create a path with a space var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: "path with spaces"); @@ -117,10 +111,8 @@ public void NativeAot_app_publishes_with_space_in_path(string targetFramework) DoSymbolsExist(publishDirectory, testProject.Name).Should().BeTrue($"{publishDirectory} should contain {testProject.Name} symbol"); IsNativeImage(publishedExe).Should().BeTrue(); - bool useRuntimePackLayout = targetFramework is not ("net7.0" or "net8.0" or "net9.0"); - GetKnownILCompilerPackVersion(testAsset, targetFramework, out string expectedVersion); - CheckIlcVersions(testAsset, targetFramework, rid, expectedVersion, useRuntimePackLayout); + CheckIlcVersions(testAsset, targetFramework, rid, expectedVersion, useRuntimePackLayout: true); var command = new RunExeCommand(Log, publishedExe) .Execute().Should().Pass()