consuming-dotnettool — Claude Code rule: what it does, how to install
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.
Apache-2.0 ★ 138 updated 2025-03-29
.cursor/rules/consuming-dotnettool.mdcWhat consuming-dotnettool does
consuming-dotnettool sets project guidance for consuming dotnet tool packages in .NET projects. It asks the project to keep a manifest at .config/dotnet-tools.json, pin every tool to an explicit version, and commit that file to version control. A new manifest starts with dotnet new tool-manifest; packages are added with dotnet tool install <tool-package> --version <version>.
The rule covers installation, updates, restoration, and periodic manifest checks. It also asks for tool purpose and troubleshooting notes in the README or contributing guidelines. CI/CD should run dotnet tool restore before build or test stages, verify expected versions, and may cache restored tools between runs. Security guidance covers trusted sources, licensing, and avoiding wildcard or range versions.
CI/CD must restore tools before build or test, or those stages will not have the manifest dependencies prepared by this process.
What it helps with
- create a manifest for project-local .NET tools
- pin
dotnet toolpackages to explicit versions - restore tools before build and test jobs
- update a tool without changing its version implicitly
- audit the manifest for unused or outdated tools
Example prompts for the agent
- Set up
.config/dotnet-tools.jsonfor this .NET project and explain which tools belong in it. - Create the manifest with
dotnet new tool-manifest, then add<tool-package>at version<version>. - Add
dotnet tool restorebefore the build and test stages in the CI/CD pipeline, then document the tools in the README.
How to install consuming-dotnettool
Manually: put the files in place
.cursor/rules/consuming-dotnettool.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/consuming-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/consuming-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/consuming-dotnettool.mdManually: put the files in place
.clinerules/consuming-dotnettool.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about consuming-dotnettool
How do I install consuming-dotnettool in Claude Code?
Create the rule file at .claude/rules/consuming-dotnettool.md and place the consuming-dotnettool contents there.
What does consuming-dotnettool do?
It guides projects to manage dotnet tool dependencies through a committed manifest, explicit versions, restore steps, and maintenance documentation.
Which platforms support consuming-dotnettool?
The rule is provided for Claude Code and Cursor. Claude Code uses .claude/rules/consuming-dotnettool.md, while Cursor uses .cursor/rules/consuming-dotnettool.mdc.
Source text
consuming-dotnettool.mdc · Apache-2.0
---
description: This tool is used for helping manage and organize the installation of `dotnet tool` instances that are used for .NET projects.
globs:
alwaysApply: false
---
# Cursor Rules File: Best Practices for Consuming dotnet Tool Instances
# This file provides guidelines for projects that depend on dotnet tools. It ensures that:
# - A tool manifest is maintained for local and CI/CD consistency.
# - Tool versions are explicitly defined.
# - Proper installation, updating, and documentation practices are followed.
General:
Description: >
Projects consuming dotnet tool instances must manage their tool dependencies through a tool manifest.
This approach promotes reproducible builds and clear dependency management, ensuring that the correct
tool versions are used consistently across different environments.
Requirements:
- Maintain a tool manifest file (typically located at `.config/dotnet-tools.json`) in the project root.
- Use explicit versioning for all dotnet tools to prevent unexpected updates.
- Integrate tool management into the CI/CD pipeline for automated restoration.
Preparation:
- If a tool manifest does not exist, create one by running:
- `dotnet new tool-manifest`
- Update the tool manifest with the necessary tools by executing:
- `dotnet tool install <tool-package> --version <version>`
- Ensure the manifest file (`.config/dotnet-tools.json`) is checked into version control for consistency.
Tool Management:
- Installation:
- Use `dotnet tool install` with an explicit version to add a tool to the manifest.
- Verify that the installed tool versions match the ones specified in the manifest.
- For tools that support both global and local installation, prefer local installation via manifest.
- Updating:
- To update a tool, use `dotnet tool update <tool-package> --version <version>`.
- After updating, validate that the manifest reflects the new version.
- Restoration:
- Ensure that `dotnet tool restore` is executed as part of local setup and CI/CD processes to install all tools defined in the manifest.
- Verification:
- Periodically review the manifest to confirm that all tool versions are current and that deprecated or unused tools are removed.
Integration & CI/CD:
- Include the following steps in your CI/CD pipeline:
- **Restore Tools:** Run `dotnet tool restore` prior to build or test phases.
- **Version Check:** Validate that the manifest has not drifted from the expected tool versions.
- **Cache Tools:** Consider caching the restored tools between pipeline runs to improve build times.
- Document the usage of these tools in your project README or contributing guidelines for clarity.
Documentation & Maintenance:
- Document in your project README:
- The purpose of each dotnet tool listed in the manifest.
- Instructions for installing, updating, or troubleshooting the tools.
- Regularly audit the manifest to:
- Remove outdated or unused tools.
- Update tools when new versions become available and are verified for compatibility.
- Maintain clear commit messages when changes are made to the tool manifest.
Security & Compliance:
- Ensure that all tools come from trusted sources and have proper licensing.
- Avoid using wildcard or range versioning to mitigate the risk of unintentional upgrades.
- Document any security advisories or considerations related to the consumed tools.
Automation:
- Automate tool restoration by incorporating `dotnet tool restore` into your build scripts.
- Consider using scripts or CI/CD tasks to:
- Check for available updates to the tools.
- Validate the integrity and security compliance of the manifest file.
- Monitor for security advisories related to installed tools.
- Automatically create PRs for tool updates after successful testing.
# End of Cursor Rules File
© Aaronontheweb · Apache-2.0 · Aaronontheweb/dotnet-cursor-rules