Skip to content

Disambiguate duplicate paths in aspire ps output#16199

Merged
JamesNK merged 4 commits intomainfrom
jamesn/shorten-paths-disambiguate
Apr 16, 2026
Merged

Disambiguate duplicate paths in aspire ps output#16199
JamesNK merged 4 commits intomainfrom
jamesn/shorten-paths-disambiguate

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Apr 15, 2026

Description

Disambiguate duplicate paths in aspire ps table output.

Previously, ShortenPath processed each path independently, so two AppHosts at c:\folder1\Project.csproj and c:\folder2\Project.csproj would both display as Project.csproj. The new ShortenPaths method compares all paths together and adds the minimum number of parent directory segments needed to make each display value unique.

Key behaviors:

  • Unique filenames: shown as just the filename (e.g. MyApp.AppHost.csproj)
  • Duplicate filenames: parent directories are added with a ~\ prefix until unique (e.g. ~\folder1\Project.csproj)
  • Single-file AppHosts (.cs files): always include at least the parent folder for context (e.g. MyApp\AppHost.cs)
  • Root segments: when disambiguation would reach a drive letter or leading /, the full original path is used instead

The method was moved from PsCommand to FileSystemHelper for reusability and testability.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings April 15, 2026 07:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds path disambiguation to aspire ps output by shortening paths across the full set of AppHosts, ensuring display values are unique while keeping them as compact as possible.

Changes:

  • Introduces FileSystemHelper.ShortenPaths(...) to compute unique shortened display paths across a list.
  • Updates PsCommand to use the new multi-path shortening logic instead of shortening each path independently.
  • Adds unit tests covering unique filenames, duplicates, .cs vs project files, and “root segment” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
tests/Aspire.Cli.Tests/Utils/FileSystemHelperTests.cs Adds coverage for ShortenPaths behaviors (unique/duplicate, csproj/cs, root handling).
src/Aspire.Cli/Utils/FileSystemHelper.cs Implements ShortenPaths and moves path-shortening responsibilities into a reusable helper.
src/Aspire.Cli/Commands/PsCommand.cs Switches aspire ps table rendering to use FileSystemHelper.ShortenPaths.

Comment thread src/Aspire.Cli/Utils/FileSystemHelper.cs Outdated
Comment thread src/Aspire.Cli/Utils/FileSystemHelper.cs Outdated
Comment thread src/Aspire.Cli/Utils/FileSystemHelper.cs Outdated
Comment thread tests/Aspire.Cli.Tests/Utils/FileSystemHelperTests.cs
Comment thread tests/Aspire.Cli.Tests/Utils/FileSystemHelperTests.cs
ShortenPaths now compares all paths together and adds enough parent
directory segments to make each display value unique. For example,
c:\folder1\Project.csproj and c:\folder2\Project.csproj are shown as
their full paths instead of both appearing as Project.csproj.

Non-project files (single-file AppHosts like AppHost.cs) always include
at least the parent folder for context (e.g. MyApp\AppHost.cs).

When further disambiguation would reach a path root (drive letter or
leading separator), the full original path is used instead of a ~\
prefix.
@JamesNK JamesNK force-pushed the jamesn/shorten-paths-disambiguate branch from b252251 to 8c2dfd2 Compare April 15, 2026 07:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16199

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16199"

Comment thread src/Aspire.Cli/Utils/FileSystemHelper.cs Outdated
JamesNK added 2 commits April 16, 2026 07:44
Address code review feedback: the GroupBy for duplicate detection was
using a hardcoded OrdinalIgnoreCase comparer instead of the platform-aware
one, which could cause an infinite loop on case-sensitive filesystems
(Linux/macOS) when paths differ only by case.

Added a test that verifies paths differing only by case are treated as
distinct on Linux.
@JamesNK JamesNK enabled auto-merge (squash) April 16, 2026 00:07
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 71 recordings uploaded (commit c1cf7cf)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24484350643

@JamesNK
Copy link
Copy Markdown
Member Author

JamesNK commented Apr 16, 2026

Feedback applied

@JamesNK JamesNK merged commit b1f95fc into main Apr 16, 2026
556 of 559 checks passed
@github-actions github-actions Bot added this to the 13.3 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants