feat: add bacon hosting integration#1302
Merged
Merged
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1302Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1302" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a bacon-based option to the existing Rust hosting integration so Rust apps can be run via Bacon instead of Cargo, while reusing the existing RustAppExecutableResource and defaults.
Changes:
- Introduces
AddBaconApp(...)extension method that creates aRustAppExecutableResourceusing thebaconcommand. - Refactors the internal resource creation path to support selecting the executable command (
cargovsbacon). - Adds unit tests covering
AddBaconAppbehavior and argument validation.
Show a summary per file
| File | Description |
|---|---|
| tests/CommunityToolkit.Aspire.Hosting.Rust.Tests/BaconAppPublicApiTests.cs | Adds null/argument validation tests for AddBaconApp. |
| tests/CommunityToolkit.Aspire.Hosting.Rust.Tests/AddBaconAppTests.cs | Adds model/metadata tests verifying the created resource uses bacon and expected args. |
| src/CommunityToolkit.Aspire.Hosting.Rust/RustAppHostingExtension.cs | Adds AddBaconApp and refactors Rust app creation to allow choosing the command. |
| src/CommunityToolkit.Aspire.Hosting.Rust/RustAppExecutableResource.cs | Extends the resource constructor to accept an optional command (defaulting to cargo). |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 5
Comment on lines
33
to
+38
| string[] allArgs = args is { Length: > 0 } | ||
| ? ["run", .. args] | ||
| : ["run"]; | ||
|
|
||
| return builder.AddRustApp(name, workingDirectory, command: "cargo", allArgs); | ||
| } |
Comment on lines
+60
to
+65
| string[] allArgs = args is { Length: > 0 } | ||
| ? args | ||
| : ["run"]; | ||
|
|
||
| return builder.AddRustApp(name, workingDirectory, command: "bacon", allArgs); | ||
| } |
Comment on lines
13
to
20
| /// <summary> | ||
| /// Adds a Rust application to the application model. Executes the executable Rust app. | ||
| /// Adds a Rust application to the application model, using the cargo cli. | ||
| /// </summary> | ||
| /// <param name="builder">The <see cref="IDistributedApplicationBuilder"/> to add the resource to.</param> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="workingDirectory">The working directory to use for the command.</param> | ||
| /// <param name="args">The optional arguments to be passed to the executable when it is started.</param> | ||
| /// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns> |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
aaronpowell
approved these changes
May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I often, if not always, use bacon to run a Rust app in Aspire. Bacon is the best solution to run background jobs for Rust apps.
Part of #1048
PR Checklist
Other information
Note: on how bacon works, the default command run if none provided is
bacon check, equivalent tocargo check. It has no interest to runcheckby default for an Aspire resource. That's why I made it consistent withAddRustAppto useruncommand by default. But the main difference is that I allow any command override (not justrun <args>), in order to allow additional tasks likecheck,clippy,test, etc..Question: I would want to do the same for
AddRustAppbut that introduce a breaking change. One would want to have a "test" run for example.For information, the default solution
cargo-watchis no longer maintained and Bacon is one of the recommended solution.