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
.cursor/rules/publishing-dotnettool.mdcWhat 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.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/publishing-dotnettool.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/publishing-dotnettool.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/publishing-dotnettool.mdManually: put the files in place
.clinerules/publishing-dotnettool.mdStep 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