Skip to content

Remove redundant Path.GetDirectoryName call and rename _appPath/_AppPath to _appDirectoryPath/AppDirectoryPath in PrebuiltAppHostServer - #15332

Merged
Jose Perez Rodriguez (joperezr) merged 3 commits into
release/13.2from
copilot/remove-path-getdirectoryname-call
Mar 18, 2026
Merged

Jose Perez Rodriguez (joperezr) merged 3 commits into
release/13.2from
copilot/remove-path-getdirectoryname-call

Conversation

Copilot AI commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Customer Impact

With aspire polyglot, NuGet.config files in the same directory as the apphost aren't respected.

Description

_appPath in PrebuiltAppHostServer already holds a directory path, making the Path.GetDirectoryName calls redundant. This cleans up two such callsites, renames the private field to _appDirectoryPath, and renames the public property AppPath to AppDirectoryPath to accurately reflect their semantics.

Changes in PrebuiltAppHostServer.cs:

  • Renamed _appPath → _appDirectoryPath throughout
  • Renamed AppPath property → AppDirectoryPath
  • RestoreNuGetPackagesAsync: removed intermediate appHostDirectory local and pass _appDirectoryPath directly as workingDirectory
  • ResolveChannelNameAsync: removed Path.GetDirectoryName(_appPath)! and pass _appDirectoryPath directly to AspireJsonConfiguration.Load

Changes in IAppHostServerProject.cs:

  • Renamed AppPath property → AppDirectoryPath

Changes in DotNetBasedAppHostServerProject.cs:

  • Renamed AppPath property → AppDirectoryPath

Before:

var appHostDirectory = Path.GetDirectoryName(_appPath);
return await _nugetService.RestorePackagesAsync(..., workingDirectory: appHostDirectory, ...);

After:

return await _nugetService.RestorePackagesAsync(..., workingDirectory: _appDirectoryPath, ...);

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

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI and others added 2 commits March 17, 2026 17:26

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • centralus-2.in.applicationinsights.azure.com
    • Triggering command: /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests --internal-msbuild-node /home/REDACTED/.local/share/c3763b7b477943e6978acca6c0d47ec9/.p --filter-not-trait category=failing --filter-not-trait quarantined=true --filter-not-trait outerloop=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests.deps.json /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Microsoft.DotNet.RemoteExecutor.dll Aspire.Cli.Tests, Version=42.42.42.42, Culture=neutral, PublicKeyToken=null Aspire.Cli.Tests.CliSmokeTests+<>c <LocaleOverrideReturnsExitCode>b__4_0 /tmp/bespesno.343 invalid-locale False ASPIRE_LOCALE_OVERRIDE (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Aspire.Cli.Tests.deps.json /home/REDACTED/work/aspire/aspire/artifacts/bin/Aspire.Cli.Tests/Debug/net10.0/Microsoft.DotNet.RemoteExecutor.dll Aspire.Cli.Tests, Version=42.42.42.42, Culture=neutral, PublicKeyToken=null Aspire.Cli.Tests.CliSmokeTests+<>c <LocaleOverrideReturnsExitCode>b__4_0 /tmp/bespesno.343 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Remove redundant Path.GetDirectoryName call and rename _appPath to _appDirectoryPath in PrebuiltAppHostServer Remove redundant Path.GetDirectoryName call and rename _appPath/_AppPath to _appDirectoryPath/AppDirectoryPath in PrebuiltAppHostServer Mar 17, 2026
@eerhardt
Eric Erhardt (eerhardt) marked this pull request as ready for review March 17, 2026 22:07
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15332

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR clarifies and standardizes “app path” semantics for CLI AppHost server projects by treating the value as a directory path and removing redundant/incorrect Path.GetDirectoryName usage.

Changes:

  • Renamed AppPath → AppDirectoryPath on IAppHostServerProject and updated implementations.
  • Renamed PrebuiltAppHostServer’s backing field to _appDirectoryPath and removed redundant Path.GetDirectoryName call sites.
  • Simplified NuGet restore/config loading to operate directly on the app host directory path.

Reviewed changes

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

File Description
src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs Renames internal storage to _appDirectoryPath and uses it directly for NuGet restore working directory and local .aspire/settings.json loading.
src/Aspire.Cli/Projects/IAppHostServerProject.cs Renames the interface property to AppDirectoryPath to reflect directory semantics.
src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs Updates the implementation to expose AppDirectoryPath (mapped to existing normalized _appPath).

@joperezr Jose Perez Rodriguez (joperezr) added the Servicing-approved Approved for servicing release label Mar 18, 2026
@joperezr
Jose Perez Rodriguez (joperezr) merged commit 777972e into release/13.2 Mar 18, 2026
508 of 511 checks passed
@joperezr
Jose Perez Rodriguez (joperezr) deleted the copilot/remove-path-getdirectoryname-call branch March 18, 2026 17:53
@dotnet-policy-service dotnet-policy-service Bot added this to the 13.2 milestone Mar 18, 2026
Copilot AI added a commit that referenced this pull request Mar 18, 2026
…ath to _appDirectoryPath/AppDirectoryPath in PrebuiltAppHostServer (#15332)

* Initial plan

* Remove Path.GetDirectoryName call and rename _appPath to _appDirectoryPath in PrebuiltAppHostServer

Co-authored-by: eerhardt <[email protected]>

* Rename AppPath property to AppDirectoryPath in IAppHostServerProject and implementations

Co-authored-by: eerhardt <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: eerhardt <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants