Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

dotnet-cli-distributiondotnet CLI distribution 命令行

Agent Skill

dotnet-cli-distribution 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

412

周安装

17

GitHub Stars

15

下载量

135
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dotnet-cli-distribution(dotnet CLI distribution 命令行)
来源仓库:https://github.com/wshaddix/dotnet-skills
仓库路径:skills/dotnet-cli-distribution
安装命令:
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-cli-distribution
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-cli-distribution

简介

dotnet-cli-distribution 制定 .NET 工具的跨平台分发策略。

  • 提供 Native AOT、框架依赖和 dotnet tool 三种部署方案对比。
  • 支持 linux-x64、osx-arm64 等多平台 RID 矩阵规划。
  • 需权衡单文件发布和二进制体积优化的取舍关系。
  • 不涉及 MSBuild PublishAot 属性的具体配置细节。

SKILL.md

dotnet-cli-distribution

CLI distribution strategy for.NET tools: choosing between Native AOT single-file publish, framework-dependent deployment, and dotnet tool packaging. Runtime Identifier (RID) matrix planning for cross-platform targets (linux-x64, osx-arm64, win-x64, linux-arm64), single-file publish configuration, and binary size optimization techniques for CLI applications.

Version assumptions:.NET 8.0+ baseline. Native AOT for console apps is fully supported since.NET 8. Single-file publish has been mature since.NET 6.

Out of scope: Native AOT MSBuild configuration (PublishAot, ILLink descriptors, EnableAotAnalyzer, trimming) -- see [skill:dotnet-native-aot]. AOT-first application design patterns (source gen over reflection, DI choices) -- see [skill:dotnet-aot-architecture]. Multi-platform packaging formats (Homebrew, apt/deb, winget, Scoop) -- see [skill:dotnet-cli-packaging]. Release CI/CD pipeline -- see [skill:dotnet-cli-release-pipeline]. Container-based distribution -- see [skill:dotnet-containers]. General CI/CD patterns -- see [skill:dotnet-gha-patterns] and [skill:dotnet-ado-patterns].

Cross-references: [skill:dotnet-native-aot] for AOT compilation pipeline, [skill:dotnet-aot-architecture] for AOT-safe design patterns, [skill:dotnet-cli-architecture] for CLI layered architecture, [skill:dotnet-cli-packaging] for platform-specific package formats, [skill:dotnet-cli-release-pipeline] for automated release workflows, [skill:dotnet-containers] for container-based distribution, [skill:dotnet-tool-management] for consumer-side tool installation and manifest management.


Distribution Strategy Decision Matrix

Choose the distribution model based on target audience and deployment constraints.

StrategyStartup TimeBinary SizeRuntime RequiredBest For
Native AOT single-file~10ms10-30 MBNonePerformance-critical CLI tools, broad distribution
Framework-dependent single-file~100ms1-5 MB.NET runtimeInternal tools where runtime is guaranteed
Self-contained single-file~100ms60-80 MBNoneSimple distribution without AOT complexity
dotnet tool (global/local)~200ms< 1 MB (NuGet).NET SDKDeveloper tools,.NET ecosystem users

When to Choose Each Strategy

Native AOT single-file -- the gold standard for CLI distribution:

  • Zero dependencies on target machine (no.NET runtime needed)
  • Fastest startup (~10ms vs ~100ms+ for JIT)
  • Smallest binary when combined with trimming
  • Trade-off: longer build times, no reflection unless preserved
  • See [skill:dotnet-native-aot] for PublishAot MSBuild configuration

Framework-dependent deployment:

  • Smallest artifact size (only app code, no runtime)
  • Users must have.NET runtime installed
  • Best for internal/enterprise tools where runtime is managed
  • Can still use single-file publish for convenience

Self-contained (non-AOT):

  • Includes.NET runtime in the artifact
  • Larger binary than AOT but simpler build process
  • Full reflection and dynamic code support
  • Good compromise when AOT compat is difficult

dotnet tool packaging:

  • Distributed via NuGet -- simplest publishing workflow
  • Users install with dotnet tool install -g mytool
  • Requires.NET SDK on target (not just runtime)
  • Best for developer-facing tools in the.NET ecosystem
  • See [skill:dotnet-cli-packaging] for NuGet distribution details

Runtime Identifier (RID) Matrix

Standard CLI RID Targets

Target the four primary RIDs for broad coverage:

RIDPlatformNotes
linux-x64Linux x86_64Most Linux servers, CI runners, WSL
linux-arm64Linux ARM64AWS Graviton, Raspberry Pi 4+, Apple Silicon VMs
osx-arm64macOS Apple SiliconM1/M2/M3+ Macs (primary macOS target)
win-x64Windows x86_64Windows 10+, Windows Server

Optional Extended Targets

RIDWhen to Include
osx-x64Legacy Intel Mac support (declining market share)
linux-musl-x64Alpine Linux / Docker scratch images
linux-musl-arm64Alpine on ARM64
win-arm64Windows on ARM (Surface Pro X, Snapdragon laptops)

RID Configuration in.csproj

<!-- Set per publish, not in csproj (avoids accidental RID lock-in) -->
<!-- Use dotnet publish -r <rid> instead -->

<!-- If you must set a default for local development -->
<PropertyGroup Condition="'$(RuntimeIdentifier)' == ''">
  <RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
</PropertyGroup>

Publish per RID from the command line:

# Publish for each target RID
dotnet publish -c Release -r linux-x64
dotnet publish -c Release -r linux-arm64
dotnet publish -c Release -r osx-arm64
dotnet publish -c Release -r win-x64

Single-File Publish

Single-file publish bundles the application and its dependencies into one executable.

Configuration

<PropertyGroup>
  <PublishSingleFile>true</PublishSingleFile>
  <!-- Required for single-file -->
  <SelfContained>true</SelfContained>
  <!-- Embed PDB for stack traces (optional, adds ~2-5 MB) -->
  <DebugType>embedded</DebugType>
  <!-- Include native libraries in the single file -->
  <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>

Single-File with Native AOT

When combined with Native AOT, single-file is implicit -- AOT always produces a single native binary:

<PropertyGroup>
  <PublishAot>true</PublishAot>
  <!-- PublishSingleFile is not needed -- AOT output is inherently single-file -->
  <!-- SelfContained is implied by PublishAot -->
</PropertyGroup>

See [skill:dotnet-native-aot] for the full AOT publish configuration including ILLink, type preservation, and analyzer setup.

Publish Command

# Framework-dependent single-file (requires .NET runtime on target)
dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true --self-contained false

# Self-contained single-file (includes runtime, no AOT)
dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true --self-contained true

# Native AOT (inherently single-file, smallest and fastest)
dotnet publish -c Release -r linux-x64
# (when PublishAot=true is in csproj)

Size Optimization for CLI Binaries

Trimming (Non-AOT)

Trimming removes unused code from the published output. For self-contained non-AOT builds:

<PropertyGroup>
  <PublishTrimmed>true</PublishTrimmed>
  <TrimMode>link</TrimMode>
  <!-- Suppress known trim warnings for CLI scenarios -->
  <SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
</PropertyGroup>

AOT Size Optimization

For Native AOT builds, size is controlled by AOT-specific MSBuild properties. See [skill:dotnet-native-aot] for the full configuration. Key CLI-relevant properties include StripSymbols, OptimizationPreference, InvariantGlobalization, and StackTraceSupport.

Size Comparison (Typical CLI Tool)

ConfigurationApproximate Size
Self-contained (no trim)60-80 MB
Self-contained + trimmed15-30 MB
Native AOT (default)15-25 MB
Native AOT + size optimized8-15 MB
Native AOT + invariant globalization + stripped5-10 MB
Framework-dependent1-5 MB

Practical Size Reduction Checklist

  1. Enable invariant globalization if the tool does not need locale-specific formatting (InvariantGlobalization=true)
  2. Strip symbols on Linux/macOS (StripSymbols=true) -- keep separate symbol files for crash analysis
  3. Optimize for size (OptimizationPreference=Size) -- minimal runtime performance impact for I/O-bound CLI tools
  4. Disable reflection where possible -- use source generators for JSON serialization ([skill:dotnet-aot-architecture])
  5. Audit NuGet dependencies -- each dependency adds to the binary; remove unused packages

Framework-Dependent vs Self-Contained Trade-offs

Framework-Dependent

dotnet publish -c Release -r linux-x64 --self-contained false

Advantages:

  • Smallest artifact (1-5 MB)
  • Serviced by runtime updates (security patches applied by runtime, not app rebuild)
  • Faster publish times

Disadvantages:

  • Requires matching.NET runtime on target
  • Runtime version mismatch causes startup failures
  • Users must manage runtime installation

Self-Contained

dotnet publish -c Release -r linux-x64 --self-contained true

Advantages:

  • No runtime dependency on target
  • App controls exact runtime version
  • Side-by-side deployment (multiple apps, different runtimes)

Disadvantages:

  • Larger artifact (60-80 MB without trimming)
  • Must rebuild and redistribute for runtime security patches
  • One artifact per target RID

Publishing Workflow

Local Development

# Quick local publish for testing
dotnet publish -c Release -r osx-arm64

# Verify the binary
./bin/Release/net8.0/osx-arm64/publish/mytool --version

Producing Release Artifacts

#!/bin/bash
# build-all.sh -- Produce artifacts for all target RIDs
set -euo pipefail

VERSION="${1:?Usage: build-all.sh <version>}"
PROJECT="src/MyCli/MyCli.csproj"
OUTPUT_DIR="artifacts"

RIDS=("linux-x64" "linux-arm64" "osx-arm64" "win-x64")
# Note: Native AOT cross-compilation for ARM64 on x64 requires platform toolchain
# See [skill:dotnet-cli-release-pipeline] for CI-based cross-compilation setup

for rid in "${RIDS[@]}"; do
  echo "Publishing for $rid..."
  dotnet publish "$PROJECT" \
    -c Release \
    -r "$rid" \
    -o "$OUTPUT_DIR/$rid" \
    /p:Version="$VERSION"
done

# Create archives
for rid in "${RIDS[@]}"; do
  if [[ "$rid" == win-* ]]; then
    (cd "$OUTPUT_DIR/$rid" && zip -q "../mytool-$VERSION-$rid.zip" *)
  else
    tar -czf "$OUTPUT_DIR/mytool-$VERSION-$rid.tar.gz" -C "$OUTPUT_DIR/$rid" .
  fi
done

echo "Artifacts in $OUTPUT_DIR/"

Checksum Generation

Always produce checksums for release artifacts:

# Generate SHA-256 checksums
cd artifacts
shasum -a 256 *.tar.gz *.zip > checksums-sha256.txt

See [skill:dotnet-cli-release-pipeline] for automating this in GitHub Actions.


Agent Gotchas

  1. Do not set RuntimeIdentifier in the.csproj for multi-platform CLI tools. Hardcoding a RID in the project file prevents building for other platforms. Pass -r <rid> at publish time instead.
  2. Do not use PublishSingleFile with PublishAot. Native AOT output is inherently single-file. Setting both is redundant and may cause confusing build warnings.
  3. Do not skip InvariantGlobalization for size-sensitive CLI tools. Globalization data adds ~25 MB to AOT binaries. Most CLI tools that do not format locale-specific dates/currencies should enable InvariantGlobalization=true.
  4. Do not distribute self-contained non-trimmed binaries. A 60-80 MB CLI tool is unacceptable for end users. Either trim (PublishTrimmed), use AOT, or distribute as framework-dependent.
  5. Do not forget to produce checksums for release artifacts. Users and package managers need SHA-256 checksums to verify download integrity. See [skill:dotnet-cli-release-pipeline] for automated checksum generation.
  6. Do not hardcode secrets in publish scripts. Use environment variable placeholders (${SIGNING_KEY}) with a comment about CI secret storage for any signing or upload credentials.

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.37%
按下载量换算48

Claude

30.33%
按下载量换算41

Cursor

18.08%
按下载量换算24

Gemini CLI

8.57%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills