Skip to content

feat(MediaMtx.Cli): enhance standalone tool deployment - #1386

Merged
ArgoZhang merged 1 commit into
masterfrom
chore-cli
Dec 2, 2026
Merged

ArgoZhang merged 1 commit into
masterfrom
chore-cli

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1374

Summary By Copilot

  • Bump BootstrapBlazor.MediaMtx.Cli to 11.0.2 and align project metadata and target framework configuration.
  • Split MediaMTX preparation into --download and --copy operations, with support for --output, selected RID copy behavior, and preparing all supported RIDs.
  • Preserve the existing cache and output-file rules: cache validity is reused, missing output files are copied only as needed, and --force overwrites output files without forcing a cache download.
  • Add download URL and progress reporting, cache diagnostics, offline copy-only behavior, generated SHA-256 validation, and clearer help text.
  • Update the README for the expanded command-line workflow and runtime behavior.

Regression?

  • Yes
  • No

This changes the opt-in standalone CLI workflow without changing existing component or service implementations.

Risk

  • High
  • Medium
  • Low

The change adds download, cache, and file-copy behavior to a standalone tool. --force can overwrite output executable and license files by design; cache and output paths can be influenced by CLI options.

Verification

  • Manual (required)
  • Automated

This Issue/PR creation task performed read-only Git and GitHub checks only. The working tree is clean, local HEAD matches origin/chore-cli, and no open PR exists for head chore-cli against master. The branch does not contain the latest master commit 546de59b and should be updated before merge.

No build, pack, test, or manual CLI verification was run.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

The CLI package metadata and README inclusion were reviewed in the package project; MediaMTX binaries remain deployment-time downloads and are not bundled in the NuGet tool package.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Expand the standalone MediaMTX CLI workflow to support downloading, caching, and copying tools independently.

New Features:

  • Add separate download and cache-only copy operations, including preparation of all supported RIDs and configurable output directories.
  • Add download URL and progress reporting, cache diagnostics, and clearer command-line help.

Enhancements:

  • Reuse verified cached tools for copying, preserve existing output files by default, and let --force overwrite output files without forcing a new download.
  • Treat deployment failures and cancellation as warnings without returning a nonzero exit status.

Build:

  • Update the CLI project metadata and target framework configuration and bump its package version to 11.0.2.

Documentation:

  • Expand the CLI README with installation, command options, examples, caching, and host build and publish guidance.

@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Separate MediaMTX cache preparation from copying, adding all-RID downloads, output selection, progress reporting, and generated SHA-256 validation.

  • tools/BootstrapBlazor.MediaMtx.Cli/MediaMtxInstaller.cs L33-58, L92-104, L187-220 (+9 small edits)

Parse the expanded CLI options and route default, download, copy, and all-RID operations to the installer.

  • tools/BootstrapBlazor.MediaMtx.Cli/Program.cs L11-44, L70-76, L81-119 (+2 small edits)

Configuration

Update CLI package metadata and target framework configuration for the standalone tool release.

  • tools/BootstrapBlazor.MediaMtx.Cli/BootstrapBlazor.MediaMtx.Cli.csproj L2-10, L13 (removed lines), L16-24

Documentation

Document installation, the expanded download and copy workflow, cache behavior, deployment examples, and runtime requirements.

  • tools/BootstrapBlazor.MediaMtx.Cli/readme.md L3-16, L24, L31-123

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the enhancement New feature or request label Dec 2, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Dec 2, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 90a5115 into master Dec 2, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the chore-cli branch December 2, 2026 01:20
@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 3773e5e

#1374 feat(MediaMtx.Cli): add standalone tool deployment CLI · 7 of 9 met

# Requirement Status Notes
1 Provide a standalone .NET tool with the bb-mediamtx command. ✅ Met The project is packaged as a .NET tool with the requested command; this update sets its package version to 11.0.2.
2 Target .NET 8. ❌ Not addressed The README says the CLI targets .NET 11, rather than .NET 8.
3 Deploy MediaMTX 1.21.4 under mediamtx-tools/<RID> in the current directory, automatically detecting the platform or accepting --rid. 🟡 Partly met The output path and RID selection are supported, but the default action only copies from an existing cache; a fresh deployment requires an explicit download action.
4 Support win-x64, linux-x64, linux-arm64, linux-arm, osx-x64, and osx-arm64. ✅ Met
5 Verify release archives with SHA-256, extract only the executable and license, and reuse a verified per-version/per-RID cache with locking. ✅ Met The installer verifies the archive and cached files, extracts only the requested files, and locks the per-RID cache.
6 Skip deployment when both output files exist; otherwise copy only missing files. --force overwrites output files while reusing valid cached tools. ✅ Met Existing complete output is skipped for the default/copy-only action; otherwise copying preserves existing files unless --force is set.
7 Leave project files, tool manifests, and build/publish targets under host control. ✅ Met The CLI does not modify host projects or manifests, and the README assigns build and publish integration to the host.
8 Register the CLI project in the solution and include its README in the .NET tool package. ✅ Met The solution contains the CLI project, and the project packages readme.md.
9 Document installation, cross-platform deployment, cache behavior, offline preparation, and host-managed build/publish integration. ✅ Met The updated README covers these workflows.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tools/BootstrapBlazor.MediaMtx.Cli/Program.cs" line_range="115" />
<code_context>
 {
-    await Console.Error.WriteLineAsync("MediaMTX deployment was canceled or timed out.");
-    return 130;
+    await Console.Out.WriteLineAsync("[MediaMTX] Warning - deployment was canceled or timed out.", CancellationToken.None);
 }
-catch (Exception exception) when (exception is ArgumentException or InvalidOperationException or
</code_context>
<issue_to_address>
**Failed deployments report success**

When a build or publish invokes the CLI and parsing, downloading, cache validation, copying, or cancellation fails, `Program` catches cancellation and every other exception, prints a warning, and exits normally with status 0; build or publish automation therefore reports success even when parsing, downloading, cache validation, or copying failed and the output is missing MediaMTX files.

Return a nonzero exit status for failed operations, or make success-on-failure an explicit opt-in that host automation can handle deliberately.

Also at `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:117-120`.
</issue_to_address>

### Comment 2
<location path="tools/BootstrapBlazor.MediaMtx.Cli/Program.cs" line_range="115" />
<code_context>
 {
-    await Console.Error.WriteLineAsync("MediaMTX deployment was canceled or timed out.");
-    return 130;
+    await Console.Out.WriteLineAsync("[MediaMTX] Warning - deployment was canceled or timed out.", CancellationToken.None);
 }
-catch (Exception exception) when (exception is ArgumentException or InvalidOperationException or
</code_context>
<issue_to_address>
**Failed copies report success**

When a forced copy is interrupted or encounters an I/O error after replacing one output file but before replacing the other, `CopyToolsAsync` can replace the executable and then fail before replacing the license; `Program` catches the exception and returns success, and a later non-forced copy skips because both files exist, leaving a mixed deployment in place.

Commit the executable and license as one recoverable deployment, or ensure failed copies are reported as failures and subsequent copies detect and repair an incomplete pair.
</issue_to_address>

### Comment 3
<location path="tools/BootstrapBlazor.MediaMtx.Cli/Program.cs" line_range="101" />
<code_context>
+    {
+        throw new ArgumentException("Option '--force' requires copying; use it with '--copy'.");
+    }
+    var defaultAction = !download && !copy;
+    if (download && rid == "all")
+    {
</code_context>
<issue_to_address>
**Deployment succeeds without MediaMTX**

When the default action runs with an empty cache, `defaultAction` calls `MediaMtxInstaller.DeployAsync` with `download` false, so cache validation fails and the CLI reports a warning while exiting successfully; the documented deployment finishes without MediaMTX files.

Make the default action download the required files before copying them, or otherwise ensure a missing cache causes deployment to fail rather than report success.

Also at `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:109-110`.
</issue_to_address>

### Comment 4
<location path="tools/BootstrapBlazor.MediaMtx.Cli/readme.md" line_range="5" />
<code_context>
+独立的 .NET CLI 工具,用于下载、校验和缓存 [MediaMTX](https://github.com/bluenviron/mediamtx/releases),并将可执行文件和许可证复制到应用目录。工具包不包含 MediaMTX 二进制文件;`BootstrapBlazor.MediaMtx` 主包也不会自动安装 CLI 或下载 MediaMTX。

-## 使用
+CLI 目标为 .NET 11:安装工具需要 .NET SDK,运行需要 .NET 11 运行时。若只有更高主版本的运行时,需另行启用运行时 roll-forward。

-```powershell
</code_context>
<issue_to_address>
**Target .NET 8**

The issue asks for a .NET 8 tool, but the README states that this CLI targets .NET 11. Update the target framework to the requested version and keep the runtime guidance consistent.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

{
await Console.Error.WriteLineAsync("MediaMTX deployment was canceled or timed out.");
return 130;
await Console.Out.WriteLineAsync("[MediaMTX] Warning - deployment was canceled or timed out.", CancellationToken.None);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Failed deployments report success

When a build or publish invokes the CLI and parsing, downloading, cache validation, copying, or cancellation fails, Program catches cancellation and every other exception, prints a warning, and exits normally with status 0; build or publish automation therefore reports success even when parsing, downloading, cache validation, or copying failed and the output is missing MediaMTX files.

Return a nonzero exit status for failed operations, or make success-on-failure an explicit opt-in that host automation can handle deliberately.

Also at tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:117-120.

Prompt for AI agents
In `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs` at line 115:

**Failed deployments report success**

When a build or publish invokes the CLI and parsing, downloading, cache validation, copying, or cancellation fails, `Program` catches cancellation and every other exception, prints a warning, and exits normally with status 0; build or publish automation therefore reports success even when parsing, downloading, cache validation, or copying failed and the output is missing MediaMTX files.

Return a nonzero exit status for failed operations, or make success-on-failure an explicit opt-in that host automation can handle deliberately.

Also at `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:117-120`.

{
await Console.Error.WriteLineAsync("MediaMTX deployment was canceled or timed out.");
return 130;
await Console.Out.WriteLineAsync("[MediaMTX] Warning - deployment was canceled or timed out.", CancellationToken.None);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Failed copies report success

When a forced copy is interrupted or encounters an I/O error after replacing one output file but before replacing the other, CopyToolsAsync can replace the executable and then fail before replacing the license; Program catches the exception and returns success, and a later non-forced copy skips because both files exist, leaving a mixed deployment in place.

Commit the executable and license as one recoverable deployment, or ensure failed copies are reported as failures and subsequent copies detect and repair an incomplete pair.

Prompt for AI agents
In `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs` at line 115:

**Failed copies report success**

When a forced copy is interrupted or encounters an I/O error after replacing one output file but before replacing the other, `CopyToolsAsync` can replace the executable and then fail before replacing the license; `Program` catches the exception and returns success, and a later non-forced copy skips because both files exist, leaving a mixed deployment in place.

Commit the executable and license as one recoverable deployment, or ensure failed copies are reported as failures and subsequent copies detect and repair an incomplete pair.

{
throw new ArgumentException("Option '--force' requires copying; use it with '--copy'.");
}
var defaultAction = !download && !copy;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Deployment succeeds without MediaMTX

When the default action runs with an empty cache, defaultAction calls MediaMtxInstaller.DeployAsync with download false, so cache validation fails and the CLI reports a warning while exiting successfully; the documented deployment finishes without MediaMTX files.

Make the default action download the required files before copying them, or otherwise ensure a missing cache causes deployment to fail rather than report success.

Also at tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:109-110.

Prompt for AI agents
In `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs` at line 101:

**Deployment succeeds without MediaMTX**

When the default action runs with an empty cache, `defaultAction` calls `MediaMtxInstaller.DeployAsync` with `download` false, so cache validation fails and the CLI reports a warning while exiting successfully; the documented deployment finishes without MediaMTX files.

Make the default action download the required files before copying them, or otherwise ensure a missing cache causes deployment to fail rather than report success.

Also at `tools/BootstrapBlazor.MediaMtx.Cli/Program.cs:109-110`.

From #1374:

Deploy MediaMTX 1.21.4 under `mediamtx-tools/<RID>` in the current directory, automatically detecting the platform or accepting `--rid`.

独立的 .NET CLI 工具,用于下载、校验和缓存 [MediaMTX](https://github.com/bluenviron/mediamtx/releases),并将可执行文件和许可证复制到应用目录。工具包不包含 MediaMTX 二进制文件;`BootstrapBlazor.MediaMtx` 主包也不会自动安装 CLI 或下载 MediaMTX。

## 使用
CLI 目标为 .NET 11:安装工具需要 .NET SDK,运行需要 .NET 11 运行时。若只有更高主版本的运行时,需另行启用运行时 roll-forward。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Target .NET 8

The issue asks for a .NET 8 tool, but the README states that this CLI targets .NET 11. Update the target framework to the requested version and keep the runtime guidance consistent.

Prompt for AI agents
In `tools/BootstrapBlazor.MediaMtx.Cli/readme.md` at line 5:

**Target .NET 8**

The issue asks for a .NET 8 tool, but the README states that this CLI targets .NET 11. Update the target framework to the requested version and keep the runtime guidance consistent.

From #1374:

Target .NET 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(MediaMtx.Cli): add standalone tool deployment CLI

1 participant