Skip to content

Update aspire deploy command to use temporary directory as default output path #10642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 23, 2025

Summary

Updates the aspire deploy command to use a temporary output directory as the default when no --output-path is specified, instead of using {current-directory}/deploy.

Problem

Previously, the aspire deploy command would default to creating deployment artifacts in a deploy subdirectory of the current working directory. This could lead to:

  • Interference between multiple deploy operations
  • Cluttering of project directories
  • Potential conflicts when running deploys from the same directory

Solution

Modified DeployCommand.GetDefaultOutputPath() to generate unique temporary directories:

Before:

protected override string GetDefaultOutputPath(ArgumentResult result) => Path.Combine(Environment.CurrentDirectory, "deploy");

After:

protected override string GetDefaultOutputPath(ArgumentResult result) => Path.Combine(Path.GetTempPath(), $"aspire-deploy-{Guid.NewGuid():N}");

Benefits

  • Isolation: Each deploy operation gets its own unique directory
  • Cleanup: System handles temporary directory cleanup automatically
  • Cross-platform: Uses Path.GetTempPath() for platform compatibility
  • Backward compatibility: Users can still specify custom paths via --output-path

Example

# Before: would create ./deploy/
aspire deploy

# After: creates /tmp/aspire-deploy-abc123def456.../
aspire deploy

# Custom path still works as before
aspire deploy --output-path ./my-custom-deploy

Testing

  • Added unit test DeployCommandUsesTemporaryDirectoryAsDefaultOutputPath to verify the new behavior
  • Manually verified CLI shows temporary paths in help output
  • Confirmed each invocation generates unique directories
  • Build and existing tests pass without issues

The change is minimal and surgical - only one line modified in the core functionality while maintaining all existing behavior for users who specify custom output paths.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…tput path

Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] The aspire deploy command should be updated to use a temporary output directory as the default output path when none is provided as an argument. Update aspire deploy command to use temporary directory as default output path Jul 23, 2025
@Copilot Copilot AI requested a review from captainsafia July 23, 2025 23:10
Copilot finished work on behalf of captainsafia July 23, 2025 23:10
…f manual GUID approach

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
@Copilot Copilot AI requested a review from davidfowl July 23, 2025 23:36
Copilot finished work on behalf of davidfowl July 23, 2025 23:36
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
@Copilot Copilot AI requested a review from captainsafia July 23, 2025 23:55
Copilot finished work on behalf of captainsafia July 23, 2025 23:55
@captainsafia captainsafia marked this pull request as ready for review July 24, 2025 00:10
@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 00:10
Copy link
Contributor

@Copilot 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

Updates the aspire deploy command to use temporary directories as the default output path instead of creating a deploy subdirectory in the current working directory. This change improves isolation between deploy operations and prevents directory clutter.

  • Changed default output path generation to use system temporary directories with unique naming
  • Added comprehensive unit test to verify the new temporary directory behavior
  • Maintains backward compatibility for users specifying custom --output-path values

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Aspire.Cli/Commands/DeployCommand.cs Modified GetDefaultOutputPath to generate unique temporary directories using Directory.CreateTempSubdirectory
tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs Added unit test to verify temporary directory usage and validate naming patterns

@@ -24,7 +24,7 @@ public DeployCommand(IDotNetCliRunner runner, IInteractionService interactionSer

protected override string GetOutputPathDescription() => DeployCommandStrings.OutputPathArgumentDescription;

protected override string GetDefaultOutputPath(ArgumentResult result) => Path.Combine(Environment.CurrentDirectory, "deploy");
protected override string GetDefaultOutputPath(ArgumentResult result) => Directory.CreateTempSubdirectory("aspire-deploy-").FullName;
Copy link
Member

Choose a reason for hiding this comment

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

Feels weird that calling this twice will make a new directory. Should this be changed to CreateDefaultOutputPath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Renamed the method to CreateDefaultOutputPath to make it clear that it has side effects and creates a new directory each time it's called. This clarifies the semantic difference from a simple getter. Change implemented in commit fd42658.

…e effects

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
@Copilot Copilot AI requested a review from davidfowl July 24, 2025 02:08
Copilot finished work on behalf of davidfowl July 24, 2025 02:08
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.

3 participants