Skip to content

feat: add bacon hosting integration#1302

Merged
aaronpowell merged 3 commits into
CommunityToolkit:mainfrom
Odonno:feat/bacon
May 25, 2026
Merged

feat: add bacon hosting integration#1302
aaronpowell merged 3 commits into
CommunityToolkit:mainfrom
Odonno:feat/bacon

Conversation

@Odonno

@Odonno Odonno commented May 10, 2026

Copy link
Copy Markdown
Contributor

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

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Note: on how bacon works, the default command run if none provided is bacon check, equivalent to cargo check. It has no interest to run check by default for an Aspire resource. That's why I made it consistent with AddRustApp to use run command by default. But the main difference is that I allow any command override (not just run <args>), in order to allow additional tasks like check, clippy, test, etc..

Question: I would want to do the same for AddRustApp but that introduce a breaking change. One would want to have a "test" run for example.

For information, the default solution cargo-watch is no longer maintained and Bacon is one of the recommended solution.

@Odonno Odonno requested a review from Alirexaa as a code owner May 10, 2026 10:27
@github-actions

github-actions Bot commented May 10, 2026

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/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1302

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1302"

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

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 a RustAppExecutableResource using the bacon command.
  • Refactors the internal resource creation path to support selecting the executable command (cargo vs bacon).
  • Adds unit tests covering AddBaconApp behavior 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>
Comment thread src/CommunityToolkit.Aspire.Hosting.Rust/RustAppHostingExtension.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@aaronpowell aaronpowell merged commit 35bda2e into CommunityToolkit:main May 25, 2026
15 checks passed
@Odonno Odonno deleted the feat/bacon branch May 25, 2026 08:41
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