Communityコーディング&開発github.com

dotnet-local-tools

dotnet-tools.json を使用してローカル .NET ツールを管理し、開発環境と CI/CD パイプライン間で一貫したツール環境を実現します。

dotnet-local-tools とは?

このスキルは、.NET CLI のローカルツール機能を活用するための包括的なガイドです。従来のグローバルツールとは異なり、ローカルツールはリポジトリごとにインストール・バージョン管理され、`.config/dotnet-tools.json` に定義されます。`dotnet tool restore` コマンド一つでチーム全体が同一のツールセットを利用できるため、バージョンの競合を防ぎ、CI/CD パイプラインとの一貫性を保証します。DocFX、Entity Framework Core、ReportGenerator、CSharpier、Incrementalist などの一般的なツールのインストール手順、設定例、使用法を網羅しており、GitHub Actions や Azure Pipelines との統合例も提供します。また、`isRoot` の設定やバージョンの固定 (`rollForward: false`) といったベストプラクティスに加え、トラブルシューティング手順も含まれているため、.NET プロジェクトにおけるツール管理の標準的なエコシステムを構築できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Aaronontheweb/dotnet-skills/tree/main/skills/local-tools

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

.NET ローカルツール

このスキルを使用するタイミング

以下の場合にこのスキルを使用します:

  • 開発チーム全体で一貫したツール環境を設定する
  • CI/CD パイプラインがローカル開発と同じツールバージョンを使用することを保証する
  • プロジェクト固有の CLI ツール(docfx、incrementalist、dotnet-ef など)を管理する
  • プロジェクト間でのグローバルツールのバージョン競合を回避する

ローカルツールとは?

ローカルツールは、グローバルではなくリポジトリごとにインストールおよびバージョン管理される .NET CLI ツールです。これらは .config/dotnet-tools.json に定義され、dotnet tool restore で復元されます。

ローカルツールとグローバルツールの比較

項目グローバルツールローカルツール
インストールdotnet tool install -gdotnet tool restore
スコープマシン全体リポジトリごと
バージョン管理手動.config/dotnet-tools.json 内
CI/CD各ツールをインストールする必要あり単一の restore コマンド
競合バージョン競合の可能性ありプロジェクトごとに分離

ローカルツールの設定

マニフェストの初期化

# .config/dotnet-tools.json を作成
 dotnet new tool-manifest

これにより以下が作成されます:

.config/
└── dotnet-tools.json

ローカルにツールをインストール

# ツールをローカルにインストール
 dotnet tool install docfx

# 特定のバージョンをインストール
 dotnet tool install docfx --version 2.78.3

# 特定のソースからインストール
 dotnet tool install MyTool --add-source https://mycompany.pkgs.visualstudio.com/_packaging/feed/nuget/v3/index.json

ツールの復元

# マニフェストからすべてのツールを復元
 dotnet tool restore

dotnet-tools.json の形式

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "docfx": {
      "version": "2.78.3",
      "commands": [
        "docfx"
      ],
      "rollForward": false
    },
    "dotnet-ef": {
      "version": "9.0.0",
      "commands": [
        "dotnet-ef"
      ],
      "rollForward": false
    },
    "incrementalist.cmd": {
      "version": "1.2.0",
      "commands": [
        "incrementalist"
      ],
      "rollForward": false
    },
    "dotnet-reportgenerator-globaltool": {
      "version": "5.4.1",
      "commands": [
        "reportgenerator"
      ],
      "rollForward": false
    }
  }
}

フィールド

フィールド説明
versionマニフェストスキーマのバージョン(常に1)
isRootこれをルートマニフェストとしてマーク(親ディレクトリの検索を防ぐ)
toolsツール設定の辞書
tools.<name>.versionインストールする正確なバージョン
tools.<name>.commandsツールが提供する CLI コマンド
tools.<name>.rollForward新しいバージョンを許可するか(再現性のため通常は false)

一般的なツール

ドキュメント

# DocFX - API ドキュメントジェネレーター
 dotnet tool install docfx
"docfx": {
  "version": "2.78.3",
  "commands": ["docfx"],
  "rollForward": false
}

使用法:

dotnet docfx docfx.json
dotnet docfx serve _site

Entity Framework Core

# EF Core マイグレーション用 CLI
 dotnet tool install dotnet-ef
"dotnet-ef": {
  "version": "9.0.0",
  "commands": ["dotnet-ef"],
  "rollForward": false
}

使用法:

dotnet ef migrations add InitialCreate
dotnet ef database update

コードカバレッジ

# コードカバレッジレポート用 ReportGenerator
 dotnet tool install dotnet-reportgenerator-globaltool
"dotnet-reportgenerator-globaltool": {
  "version": "5.4.1",
  "commands": ["reportgenerator"],
  "rollForward": false
}

使用法:

dotnet reportgenerator -reports:coverage.cobertura.xml -targetdir:coveragereport -reporttypes:Html

インクリメンタルビルド

# Incrementalist - 変更されたプロジェクトのみをビルド
 dotnet tool install incrementalist.cmd
"incrementalist.cmd": {
  "version": "1.2.0",
  "commands": ["incrementalist"],
  "rollForward": false
}

使用法:

# main ブランチ以降の変更によって影響を受けるプロジェクトを取得
incrementalist --branch main

コードフォーマット

# CSharpier - 独断的な C# フォーマッター
 dotnet tool install csharpier
"csharpier": {
  "version": "0.30.3",
  "commands": ["dotnet-csharpier"],
  "rollForward": false
}

使用法:

dotnet csharpier .
dotnet csharpier --check .  # CI モード - 変更が必要な場合は失敗

コード解析

# JB dotnet-inspect (ライセンスが必要)
 dotnet tool install jb
"jb": {
  "version": "2024.3.4",
  "commands": ["jb"],
  "rollForward": false
}

CI/CD 統合

GitHub Actions

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          global-json-file: global.json

      - name: Restore tools
        run: dotnet tool restore

      - name: Build
        run: dotnet build

      - name: Test with coverage
        run: dotnet test --collect:"XPlat Code Coverage"

      - name: Generate coverage report
        run: dotnet reportgenerator -reports:**/coverage.cobertura.xml -targetdir:coveragereport

      - name: Build documentation
        run: dotnet docfx docs/docfx.json

Azure Pipelines

steps:
  - task: UseDotNet@2
    inputs:
      useGlobalJson: true

  - script: dotnet tool restore
    displayName: 'Restore .NET tools'

  - script: dotnet build -c Release
    displayName: 'Build'

  - script: dotnet test -c Release --collect:"XPlat Code Coverage"
    displayName: 'Test'

  - script: dotnet reportgenerator -reports:**/coverage.cobertura.xml -targetdir:$(Build.ArtifactStagingDirectory)/coverage
    displayName: 'Generate coverage report'

ツールバージョンの管理

ツールの更新

# 最新バージョンに更新
 dotnet tool update docfx

# 特定のバージョンに更新
 dotnet tool update docfx --version 2.79.0

インストール済みツールの一覧表示

# ローカルツールを一覧表示
 dotnet tool list

# 古いツールをチェックして一覧表示
 dotnet tool list --outdated

ツールの削除

dotnet tool uninstall docfx

ベストプラクティス

1. 常に isRoot: true を設定

MSBuild がツールマニフェストを親ディレクトリで検索するのを防ぎます:

{
  "version": 1,
  "isRoot": true,
  ...
}

2. 正確なバージョンを固定

再現可能なビルドのために "rollForward": false を使用します:

"docfx": {
  "version": "2.78.3",
  "rollForward": false
}

3. 使用前に CI で復元

ローカルツールを使用する前に必ず dotnet tool restore を実行します:

- run: dotnet tool restore
- run: dotnet docfx docs/docfx.json

4. ツール要件を文書化

README にコメントまたはセクションを追加します:

## 開発環境のセットアップ

1. ツールの復元: `dotnet tool restore`
2. ビルド: `dotnet build`
3. テスト: `dotnet test`

5. 更新に Dependabot を使用

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "nuget"
    directory: "/"
    schedule:
      interval: "weekly"
    # .config/dotnet-tools.json 内のローカルツールも含まれます

トラブルシューティング

復元後にツールが見つからない

リポジトリルートから実行していることを確認します:

# 間違い - サブディレクトリから実行
cd src/MyApp
dotnet docfx  # エラー: ツールが見つかりません

# 正しい - ソリューションルートから実行
cd ../..
dotnet docfx docs/docfx.json

バージョンの競合

バージョン競合が発生した場合、以下を確認します:

  1. 異なるバージョンのグローバルツール: dotnet tool list -g
  2. 複数のツールマニフェスト: 親ディレクトリに .config/dotnet-tools.json がないか確認

ツールキャッシュのクリア

# NuGet ツールキャッシュをクリア
dotnet nuget locals all --clear

# ツールを再復元
dotnet tool restore

例: 完全な開発環境セットアップ

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "docfx": {
      "version": "2.78.3",
      "commands": ["docfx"],
      "rollForward": false
    },
    "dotnet-ef": {
      "version": "9.0.0",
      "commands": ["dotnet-ef"],
      "rollForward": false
    },
    "dotnet-reportgenerator-globaltool": {
      "version": "5.4.1",
      "commands": ["reportgenerator"],
      "rollForward": false
    },
    "csharpier": {
      "version": "0.30.3",
      "commands": ["dotnet-csharpier"],
      "rollForward": false
    },
    "incrementalist.cmd": {
      "version": "1.2.0",
      "commands": ["incrementalist"],
      "rollForward": false
    }
  }
}

開発ワークフロー:

# 初期セットアップ
 dotnet tool restore

# コミット前にコードをフォーマット
 dotnet csharpier .

# カバレッジ付きでテストを実行
dotnet test --collect:"XPlat Code Coverage"
dotnet reportgenerator -reports:**/coverage.cobertura.xml -targetdir:coverage

# ドキュメントをビルド
dotnet docfx docs/docfx.json

# 変更されたプロジェクトを確認(大規模リポジトリ向け)
incrementalist --branch main

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

akka-hosting-actor-patterns

Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and ITimeProvider. Supports both local testing and clustered production modes.

akka-net-aspire-configuration

Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.

akka-net-best-practices

Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work distribution patterns, and cluster/local mode abstractions for testability.

akka-net-management

Akka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster formation without static seed nodes.

akka-net-testing-patterns

Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit.

api-design

Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, and versioning for NuGet packages and distributed systems.

aspire-configuration

Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.

aspire-integration-testing

Write integration tests using .NET Aspire

aspire-service-defaults

Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.

crap-analysis

Analyze code coverage and CRAP (Change Risk Anti-Patterns) scores to identify high-risk code. Use OpenCover format with ReportGenerator for Risk Hotspots showing cyclomatic complexity and untested code paths.

csharp-concurrency-patterns

Choosing the right concurrency abstraction in .NET - from async/await for I/O to Channels for producer/consumer to Akka.NET for stateful entity management. Avoid locks and manual synchronization unless absolutely necessary.

database-performance

Database access patterns for performance. Separate read/write models, avoid N+1 queries, use AsNoTracking, apply row limits, and never do application-side joins. Works with EF Core and Dapper.

dependency-injection-patterns

Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.

dotnet-devcert-trust

Diagnose and fix .NET HTTPS dev certificate trust issues on Linux. Covers the full certificate lifecycle from generation to system CA bundle inclusion, with distro-specific guidance for Ubuntu, Fedora, Arch, and WSL2.

dotnet-project-structure

Modern .NET project structure including .slnx solution format, Directory.Build.props, central package management, SourceLink, version management with RELEASE_NOTES.md, and SDK pinning with global.json.

dotnet-slopwatch

Use Slopwatch to detect LLM reward hacking in .NET code changes. Run after every code modification to catch disabled tests, suppressed warnings, empty catch blocks, and other shortcuts that mask real problems.

efcore-patterns

Entity Framework Core best practices including NoTracking by default, query splitting for navigation collections, migration management, dedicated migration services, and common pitfalls to avoid.

ilspy-decompile

Understand implementation details of .NET code by decompiling assemblies. Use when you want to see how a .NET API works internally, inspect NuGet package source, view framework implementation, or understand compiled .NET binaries.

mailpit-integration

Test email sending locally using Mailpit with .NET Aspire. Captures all outgoing emails without sending them. View rendered HTML, inspect headers, and verify delivery in integration tests.

marketplace-publishing

Workflow for publishing skills and agents to the dotnet-skills Claude Code marketplace. Covers adding new content, updating plugin.json, validation, and release tagging.

関連スキル