Skip to main content
rule CX Codex

publishing-dotnettool — rule for Claude Code and Cursor

A rule for Claude Code and Cursor that guides AI agents when creating and publishing dotnet tools to NuGet. Ensures semantic versioning, correct packaging, and compatibility across .NET versions.

Apache-2.0 ★ 138 updated 2025-03-29

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/publishing-dotnettool.mdc
Open on GitHub

What publishing-dotnettool does

The rule positions the AI as a .NET expert and open-source author, tasked with validating that the project has the right .csproj with <PackAsTool>true</PackAsTool>, package metadata (PackageId, Authors, Description, License), and full documentation including usage examples and FAQ.

During preparation, the agent checks dependencies, targets .NET 8 by default (unless the project specifies otherwise), and adds <RollForward>LatestMajor</RollForward> to enable automatic compatibility with newer runtimes. At the packaging stage, dotnet pack generates the .nupkg file with validation of contents and local test installation.

The rule applies to .cursor/rules/, .claude/rules/ and similar IDE directories. It's useful for developers publishing their own dotnet tools who want to automate quality checks via Cursor or Claude Code.

What it helps with

  • verify that a dotnet tool follows semantic versioning
  • confirm the project is correctly packaged as a NuGet package
  • validate metadata and dependencies before publication
  • enable tool compatibility with new .NET versions without re-releasing

Example prompts for the agent

  • Create a dotnet tool with the right configuration for publishing to NuGet
  • Check that my project includes <PackAsTool>true</PackAsTool> and all required metadata
  • Package and test the tool before a new release

How to install publishing-dotnettool

Manually: put the files in place

.cursor/rules/publishing-dotnettool.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about publishing-dotnettool

How do I install the publishing-dotnettool rule in Claude Code?

Copy the rule file to .claude/rules/publishing-dotnettool.md in your project root. Claude Code will automatically load it when working with dotnet tools.

What does this rule do?

It guides the AI agent to apply best practices when building dotnet tools: semantic versioning, correct NuGet packaging, compatibility across .NET versions, and complete documentation.

Which .NET version should my tool target?

The rule recommends .NET 8 (current LTS) by default. If your project targets a different version or uses multi-targeting, the rule adapts accordingly. Add <RollForward>LatestMajor</RollForward> to support newer runtimes.

Source text

publishing-dotnettool.mdc · Apache-2.0
---
description: This file serves as a guideline for the Cursor AI Agent to ensure the proper creation, packaging, and publishing of a `dotnet tool`. Follow these rules to maintain consistency, quality, and security across published tools.
globs: 
alwaysApply: false
---

# Cursor Rules File: Best Practices for Publishing a dotnet Tool
# This file serves as a guideline for the Cursor AI Agent to ensure the proper
# creation, packaging, and publishing of a dotnet tool. Follow these rules to
# maintain consistency, quality, and security across published tools.


Role Definition:
 - .NET Expert
 - OSS author
 - Aware that users running on multiple versions of .NET in different environments might need access to this tool

General:
  Description: >
    The dotnet tool must be packaged as a NuGet package that adheres to
    semantic versioning, proper dependency management, and includes comprehensive
    documentation. This file outlines the steps and checks that need to be performed.
  Requirements:
    - Use a project file (.csproj) with the property <PackAsTool>true</PackAsTool>
    - Follow semantic versioning (MAJOR.MINOR.PATCH)
    - Ensure the tool is documented with a README and inline help support

Preparation:
  - Validate that the project file includes:
      - <PackAsTool>true</PackAsTool>
      - Proper versioning and package metadata (e.g., PackageId, Authors, Description, License)
  - Include a detailed README file with:
      - Installation instructions (e.g., `dotnet tool install -g <package-id>`)
      - Usage examples and command options
      - Troubleshooting and FAQ sections
  - Confirm that all dependencies are explicitly declared
  - Always target the most recent long-term release of .NET (currently .NET 8) unless the project is explicitly set to multi-target or targets and older version of the runtime
  - Always include a `<RollForward>LatestMajor</RollForward>` so the tool can automatically be used with newer runtimes without a new version needing to be released

Packaging:
  - Use the `dotnet pack` command to generate the NuGet package:
      - Ensure that all necessary files (binaries, assets, configuration files) are included
      - Verify that the output .nupkg file contains the expected metadata and assets
  - Run tests to verify that the tool functions correctly in a local install scenario

# End of Cursor Rules File

© Aaronontheweb · Apache-2.0 · Aaronontheweb/dotnet-cursor-rules

Similar IDE rules

All IDE rules for Agent setup: memory, context, orchestration →

From the same set11

The whole set →
meta The meta rule guides edits to *.mdc files, preserving their formatting and steering agents toward existing rule files before creating new ones. CX Codex +1 ★ 138repo stars code-signing Enforces .NET code signing patterns and SignClient configuration for NuGet packages in CI/CD pipelines. CX Codex +1 ★ 138repo stars consuming-dotnettool The consuming-dotnettool rule keeps .NET tool dependencies in a manifest, pins their versions, and adds restore steps for CI/CD. Use it when projects need repeatable tool setup. CX Codex +1 ★ 138repo stars dependency-management Rule for secure NuGet dependency management: vulnerability scanning, license compliance, versioning via dotnet CLI. Auto-applies to project files. CX Codex +1 ★ 138repo stars solution-management solution-management standardizes .NET solution architecture with explicit SDK pinning, shared build properties, and centralized package management. CX Codex +1 ★ 138repo stars benchmarking The benchmarking rule teaches the agent to write valid .NET performance tests using BenchmarkDotNet. Useful when you need to measure code speed and track regressions. CX Codex +1 ★ 138repo stars nuget-package-publishing nuget-package-publishing — a rule that teaches the agent to pack .NET libraries into NuGet packages following industry standards: SPDX license, README, and debug symbols. CX Codex +1 ★ 138repo stars testing Defines xUnit testing conventions for .NET: project configurations, test isolation, coverage thresholds, and integration test setup. CX Codex +1 ★ 138repo stars

Project sponsors

Companies that keep this analytics open