Skip to main content
rule CX Codex

solution-management — Cursor & Claude Code rule: what it does

solution-management standardizes .NET solution architecture with explicit SDK pinning, shared build properties, and centralized package management.

Apache-2.0 ★ 138 updated 2025-03-29

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

What solution-management does

This rule guides the assistant when editing C# and F# projects. It applies specifically to *.sln, *.csproj, *.fsproj, global.json, and shared build configuration files.

The guidance enforces a global.json at the root with a rollForward: patch setting, central package version control via Directory.Packages.props, and restricted sources inside nuget.config. It also configures CLI build standards: deterministic artifacts, binary logging via dotnet build -bl:build.binlog, and TreatWarningsAsErrors enabled by default.

Because it treats warnings as compilation errors, applying this to legacy projects with unfixed warnings will instantly fail the build.

What it helps with

  • enable centralized NuGet package management across multiple projects
  • enforce explicit SDK versions using global.json
  • share common assembly metadata using Directory.Build.props
  • configure package source mapping inside nuget.config

Example prompts for the agent

  • Set up centralized package management for this solution using Directory.Packages.props
  • Generate a global.json file targeting .NET 8 with patch roll-forward
  • Configure Directory.Build.props to enforce TreatWarningsAsErrors across projects

How to install solution-management

Manually: put the files in place

.cursor/rules/solution-management.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 solution-management

How to install solution-management in Cursor?

Place the rule configuration into .cursor/rules/solution-management.mdc within your project root.

How to install solution-management in Claude Code?

Save the rule file into .claude/rules/solution-management.md in your repository.

When does this rule trigger?

It targets matching file globs: *.sln, global.json, Directory.Build.props, Directory.Package.props, *.csproj, and *.fsproj.

Source text

solution-management.mdc · Apache-2.0
---
description: This file provides guidelines for maintaining .NET solutions with consistent SDK versions, shared metadata, and centralized package management.
globs: *.sln, global.json, Directory.Build.props, Directory.Package.props, *.csproj, *.fsproj
alwaysApply: false
---

# Cursor Rules File: Best Practices for .NET Solution Management

Role Definition:
 - .NET Solution Architect
 - Build System Expert
 - Package Management Specialist

General:
  Description: >
    .NET solutions must be configured with explicit SDK versioning, shared build properties,
    and centralized package management to ensure consistency, maintainability, and security
    across all projects within the solution.
  Requirements:
    - Maintain a global.json for SDK version control
    - Use Directory.Build.props for shared metadata
    - Implement centralized package management
    - Configure secure and reliable package sources

SDK Version Management:
  - Maintain a global.json file in the solution root:
      - Specify exact SDK version to ensure consistent builds
      - Include rollForward policy for patch version flexibility
      - Example:
        ```json
        {
          "sdk": {
            "version": "8.0.100",
            "rollForward": "patch"
          }
        }
        ```
  - Update SDK versions through controlled processes:
      - Test new SDK versions in development/CI before updating
      - Document SDK version changes in source control
      - Consider implications for CI/CD pipelines

Shared Build Properties:
  - Implement Directory.Build.props in solution root:
      - Define common metadata:
          - Company/Author information
          - Copyright details
          - Project URL
          - License information
          - Version prefix/suffix strategy
      - Example structure:
        ```xml
        <Project>
          <PropertyGroup>
            <Authors>Your Company</Authors>
            <Company>Your Company</Company>
            <Copyright>© $([System.DateTime]::Now.Year) Your Company</Copyright>
            <PackageLicenseExpression>MIT</PackageLicenseExpression>
            <PackageProjectUrl>https://github.com/your/project</PackageProjectUrl>
            <VersionPrefix>1.0.0</VersionPrefix>
          </PropertyGroup>
        </Project>
        ```
  - Consider environment-specific overrides:
      - Use Directory.Build.targets for overrides
      - Support CI/CD pipeline customization

Package Management:
  - Enable centralized package management:
      - Create Directory.Packages.props:
          - Define package versions once
          - Enforce consistent versions across projects
          - Example:
            ```xml
            <Project>
              <PropertyGroup>
                <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
              </PropertyGroup>
              <ItemGroup>
                <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
              </ItemGroup>
            </Project>
            ```
  - Configure nuget.config:
      - Enable package source mapping
      - Define trusted package sources
      - Example:
        ```xml
        <?xml version="1.0" encoding="utf-8"?>
        <configuration>
          <packageSourceMapping>
            <packageSource key="nuget.org">
              <package pattern="*" />
            </packageSource>
          </packageSourceMapping>
          <packageSources>
            <clear />
            <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
          </packageSources>
        </configuration>
        ```

Maintenance:
  - Regular auditing:
      - Review SDK versions for security updates
      - Validate package versions for vulnerabilities
      - Update shared metadata as needed
  - Version control:
      - Commit all configuration files
      - Document changes in commit messages
      - Consider using git hooks for validation

Compilation:
  - Use dotnet CLI for builds:
      - Prefer `dotnet build` over IDE builds for consistency
      - Use `dotnet build -c Release` for release builds
      - Enable deterministic builds with `/p:ContinuousIntegrationBuild=true`
  - Enforce code quality:
      - Enable `TreatWarningsAsErrors` in Directory.Build.props:
        ```xml
        <PropertyGroup>
          <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
          <!-- Optionally allow specific warnings -->
          <WarningsNotAsErrors>CS1591</WarningsNotAsErrors>
        </PropertyGroup>
        ```
      - Address warnings properly:
          - Fix the underlying issue rather than suppressing
          - Document any necessary warning suppressions
          - Use `#pragma warning disable` sparingly and only with comments
  - Build configuration:
      - Use conditional compilation symbols purposefully
      - Define debug/release-specific behavior clearly
      - Example:
        ```xml
        <PropertyGroup>
          <DefineConstants>TRACE</DefineConstants>
          <DefineConstants Condition="'$(Configuration)'=='Debug'">$(DefineConstants);DEBUG</DefineConstants>
        </PropertyGroup>
        ```
  - Performance:
      - Enable incremental builds by default
      - Use `dotnet build --no-incremental` only when needed
      - Consider using Fast Up-to-Date Check:
        ```xml
        <PropertyGroup>
          <DisableFastUpToDateCheck>false</DisableFastUpToDateCheck>
        </PropertyGroup>
        ```
  - Build output:
      - Set consistent output paths
      - Configure deterministic output:
        ```xml
        <PropertyGroup>
          <Deterministic>true</Deterministic>
          <ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
        </PropertyGroup>
        ```
  - Error handling:
      - Log build errors comprehensively
      - Use MSBuild binary log for detailed diagnostics:
        ```bash
        dotnet build -bl:build.binlog
        ```
      - Configure error reporting in CI/CD:
        ```yaml
        - name: Build
          run: dotnet build --configuration Release /p:ContinuousIntegrationBuild=true
          env:
            DOTNET_CLI_TELEMETRY_OPTOUT: 1
            DOTNET_NOLOGO: 1
        ```

# End of Cursor Rules File 

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

Similar IDE rules

All IDE rules for Backend and APIs →

From the same set11

The whole set →
publishing-dotnettool Guides AI agents when creating and publishing dotnet tools to NuGet. Ensures semantic versioning, correct packaging, and compatibility across .NET versions. 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 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 coding-style The coding-style rule guides C# structure and style, from data types to error handling. Use it when you want an agent to follow functional patterns and keep abstractions focused. CX Codex +1 ★ 138repo stars

Project sponsors

Companies that keep this analytics open