Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Plan: Add Native AOT test with space in path

  • Explore the existing Native AOT publish tests to understand test patterns
  • Add a new test case that publishes a Native AOT app with a space in the project path
  • Build and test the changes to ensure they work correctly
  • Run code review and security checks
  • Address PR feedback - use CurrentTargetFramework and contrasting path
  • Simplify test - remove unnecessary settings and change to Fact
  • Finalize the implementation

Summary

Added a new test method NativeAot_app_publishes_with_space_in_path to the GivenThatWeWantToPublishAnAotApp test class. This test:

  1. Creates a test project with an identifier containing spaces ("path with spaces") to ensure the project path includes spaces
  2. Configures Native AOT by setting PublishAot=true
  3. Publishes the project with the Native AOT compiler
  4. Verifies the path contains a space using an assertion to ensure the test is actually running in the intended scenario
  5. Validates the output:
    • Confirms the native executable is created
    • Verifies symbol files exist
    • Checks that the output is a native image (not a .NET assembly)
    • Runs the executable and verifies it produces the expected output

The test uses ToolsetInfo.CurrentTargetFramework and is a simple Fact (not parameterized).

Changes from feedback

  • Round 1: Changed from [MemberData(nameof(Net7Plus))] to [InlineData(ToolsetInfo.CurrentTargetFramework)] to test only the latest SDK
  • Round 1: Changed identifier from "with space" to "path with spaces" for better contrast
  • Round 1: Removed unnecessary macOS/net7.0 platform check
  • Round 2: Changed from RequiresMSBuildVersionTheory with InlineData to simple Fact
  • Round 2: Removed StripSymbols setting (default in .NET 10)
  • Round 2: Removed useRuntimePackLayout conditional logic
  • Round 2: Set targetFramework directly to ToolsetInfo.CurrentTargetFramework

Security Summary

No security vulnerabilities were detected. The changes only add a new test case and do not modify any production code.

Original prompt

This section details on the original issue you should resolve

<issue_title>Test Native AOT app publish with space in the path</issue_title>
<issue_description>There should be a unit test for a project path that has a space that is published with Native AOT</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

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>
Copilot AI changed the title [WIP] Add unit test for Native AOT app publish with space in path Add unit test for Native AOT publishing with space in path Nov 11, 2025
Copilot finished work on behalf of agocke November 11, 2025 20:01
Copilot AI requested a review from agocke November 11, 2025 20:01
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

@copilot please fix

}

[RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")]
[MemberData(nameof(Net7Plus), MemberType = typeof(PublishTestUtils))]
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just test the latest supported sdk (there should be a variable for this)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use ToolsetInfo.CurrentTargetFramework in commit 900e4f6.

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");
Copy link
Member

Choose a reason for hiding this comment

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

Let’s test with a contrasting folder with a space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated identifier to "path with spaces" in commit 900e4f6.

…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>
Copilot AI requested a review from agocke November 11, 2025 20:27
Copilot finished work on behalf of agocke November 11, 2025 20:27
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

@copilot please address

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))
Copy link
Member

Choose a reason for hiding this comment

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

I think this is set by default in .NET 10, we can probably remove it. It also shouldn't matter for the specific case we're testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed StripSymbols setting in commit 1bcf1bd.

}

[RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")]
[InlineData(ToolsetInfo.CurrentTargetFramework)]
Copy link
Member

Choose a reason for hiding this comment

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

We can probably change this to Fact since it's not actually parameterized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to Fact and removed InlineData parameter in commit 1bcf1bd.

.And.HaveStdOutContaining("Hello World");
}

[RequiresMSBuildVersionTheory("17.12.0", Skip = "https://github.com/dotnet/sdk/issues/46006")]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we require a specific MSBuild version anymore. This can probably be a regular Fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to [Fact] in commit 1bcf1bd.

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");
Copy link
Member

Choose a reason for hiding this comment

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

This is unnecessary as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed useRuntimePackLayout logic and hardcoded to true in commit 1bcf1bd.

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Native AOT app publish with space in the path

2 participants