-
Notifications
You must be signed in to change notification settings - Fork 690
Implement Aspire Single-File AppHost template with CLI feature flag integration #11393
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
Conversation
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/9.5/AppHost.cs
Outdated
Show resolved
Hide resolved
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/9.5/apphost.cs
Outdated
Show resolved
Hide resolved
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/9.5/apphost.cs
Show resolved
Hide resolved
@DamianEdwards would be good to get your eyes on the template changes here, I am way out of my depth with |
Single file supports launch settings via {app}.run.json where {app}.cs is the file. That would let us mimic what we have today with normal projects. |
So maybe we don't automatically set the environment variables inside the CLI? This would preserve the ability to do |
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/.template.config/template.json
Outdated
Show resolved
Hide resolved
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/.template.config/template.json
Show resolved
Hide resolved
c6b7d27
to
624f7bc
Compare
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/.template.config/template.json
Outdated
Show resolved
Hide resolved
@@ -5,5 +5,6 @@ | |||
the Aspire.AppHost.Sdk --> | |||
<SkipAspireWorkloadManifest>true</SkipAspireWorkloadManifest> | |||
<IsAspireHost>true</IsAspireHost> | |||
<PublishAot>false</PublishAot> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't working for me when I try it locally. I think file-based apps get this property explicitly written to their virtual project file which would override this. We might have to move this to our targets file instead. I'm trying that in #11445
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works can you apply to this PR?
091c7d4
to
8e4d42a
Compare
8e4d42a
to
091c7d4
Compare
Co-authored-by: mitchdenny <[email protected]>
…late Co-authored-by: mitchdenny <[email protected]>
Co-authored-by: mitchdenny <[email protected]>
Co-authored-by: mitchdenny <[email protected]>
…e/.template.config/template.json Co-authored-by: Damian Edwards <[email protected]>
091c7d4
to
32a0df1
Compare
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11393 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11393" |
testeed |
This PR implements the Aspire Single-File AppHost template as requested in the original design discussions. The template provides a minimal, single-file approach to creating Aspire AppHost applications for scenarios where a full project structure is not needed.
Key Features
Template Structure:
apphost.cs
file with complete minimal distributed application setup using the#:sdk
directive format.csproj
,appsettings.json
, orlaunchSettings.json
files (as single-file hosts don't need them)ide.host.json
removed since VS doesn't support single-file scenarios)Version and Feature Gating:
singlefileAppHostEnabled
CLI feature flagCLI Integration:
aspire-apphost-singlefile
Usage
This creates a minimal
apphost.cs
file with complete SDK directives:Implementation Details
The template follows the existing Aspire template patterns:
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/
DotNetTemplateFactory
using the existing feature flag infrastructureChanges Made
DotNetTemplateFactory.cs
TemplatingStrings
infrastructureCliTestHelper.cs
to support the newIFeatures
dependency injectionapphost.cs
) with complete SDK directive format including:Microsoft.NET.Sdk
- Base .NET SDKAspire.AppHost.Sdk@aspireVersion
- Aspire AppHost SDKAspire.Hosting.AppHost@aspireVersion
- Required Aspire hosting packagePublishAot=false
- Disable AOT for compatibilityThe implementation is minimal and focused, providing exactly what was requested: a single-file AppHost template that integrates cleanly with the existing Aspire ecosystem while being appropriately gated for experimental use.
Created from VS Code via the GitHub Pull Request extension.
Created from VS Code via the GitHub Pull Request extension.
Created from VS Code via the GitHub Pull Request extension.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.