Skip to content

Add git repository-based templates for 'aspire new --template'#14631

Draft
mitchdenny wants to merge 3 commits intorelease/13.2from
feature/git-templates
Draft

Add git repository-based templates for 'aspire new --template'#14631
mitchdenny wants to merge 3 commits intorelease/13.2from
feature/git-templates

Conversation

@mitchdenny
Copy link
Member

Summary

Introduces a new feature flag gitTemplatesEnabled that enables using Git repositories as project templates. When enabled, adds a --template option to aspire new that accepts a local path or remote Git URL.

What's changed

  • New feature flag: gitTemplatesEnabled (default: false) in KnownFeatures
  • New --template option: Gated behind the feature flag, accepts a local directory path or a Git remote URL
  • GitTemplateService: Handles both local and remote templates:
    • Local paths: copies directory contents, excluding .git/
    • Remote URLs: git clone --depth 1 to a temp directory, copies contents, cleans up
  • Execution fork in NewCommand.ExecuteAsync: When the feature is enabled and --template is provided, it takes highest priority (before polyglot and standard template flows)
  • Destination prompt: Prompts for destination path if --output is not specified

Usage

Enable the feature:

{
  "features": {
    "gitTemplatesEnabled": true
  }
}

Then:

aspire new --template /path/to/local/repo
aspire new --template https://github.com/user/template-repo
aspire new --template https://github.com/user/template-repo --output ./my-project

Notes

This is the first iteration of the git templates feature. Future iterations will add template variable substitution, .aspire-template.json manifest support, and more.

Introduce a new feature flag 'gitTemplatesEnabled' that enables using Git
repositories as project templates. When enabled, adds a --template option
to 'aspire new' that accepts a local path or remote Git URL.

The GitTemplateService handles both local and remote templates:
- Local paths: copies directory contents excluding .git/
- Remote URLs: git clone --depth 1, copy contents, clean up

This is the first iteration of the git templates feature, providing
basic file copy functionality.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14631

Or

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 04c3722:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
ResourcesCommandShowsRunningResources ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22331698740

Mitch Denny and others added 2 commits February 24, 2026 11:23
When a git template contains a templatehost.cs file, it is now launched
as a full apphost process using the existing backchannel infrastructure
(DotNetCliRunner, JSON-RPC over Unix sockets). This allows template
authors to use IInteractionService to prompt users during template
application.

Changes:
- GitTemplateService: detect templatehost.cs, launch via DotNetCliRunner
  with backchannel, pass ASPIRE_TEMPLATE_OUTPUT_PATH env var
- Aspire.Hosting.Templating: new package skeleton with
  TemplatePromptResource and AddTemplatePrompt() extension method
- Added to Aspire.slnx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…NewCommandPrompter

Co-authored-by: Copilot <223556219+Copilot@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.

1 participant