solution-management — правило для Cursor и Claude Code
Правило solution-management задаёт стандарты организации решений .NET: фиксирует версии SDK, общие свойства сборки и централизованное управление NuGet-пакетами.
Apache-2.0 ★ 138 обновлён 2025-03-29
.cursor/rules/solution-management.mdcЧто делает solution-management
Правило настраивает поведение ассистента в контексте решений на C# и F#. Инструкции активируются при работе с файлами .sln, .csproj, .fsproj, global.json или конфигурациями Directory.Build.props и Directory.Package.props.
Внутри заложены шаблоны для global.json с политикой rollForward: patch, централизованный контроль зависимостей через Directory.Packages.props с параметром ManagePackageVersionsCentrally, а также безопасная настройка nuget.config с маппингом источников. При сборке через CLI агент будет использовать детерминированные флаги (/p:ContinuousIntegrationBuild=true) и строгий режим TreatWarningsAsErrors.
Правило требует дисциплины в версионировании: если проект не готов к трактовке предупреждений как ошибок, сборка упадёт сразу.
Какие задачи решает
- настроить централизованное управление зависимостями в .NET
- зафиксировать версию .NET SDK через global.json с rollForward
- вынести метаданные и общие параметры сборки в Directory.Build.props
- включить маппинг источников в nuget.config
Примеры запросов агенту
- Переведи солюшен на централизованное управление пакетами через Directory.Packages.props
- Создай global.json для .NET 8 с политикой обновления патчей
- Настрой Directory.Build.props со строгой обработкой предупреждений как ошибок
Как установить solution-management
Вручную: положить файлы
.cursor/rules/solution-management.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/solution-management.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/solution-management.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/solution-management.mdВручную: положить файлы
.clinerules/solution-management.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о solution-management
Как установить solution-management в Cursor?
Сохраните файл правила по пути .cursor/rules/solution-management.mdc в корне вашего проекта.
Как установить solution-management в Claude Code?
Поместите файл с текстом правила в директорию проекта по пути .claude/rules/solution-management.md.
Для каких файлов срабатывает это правило?
В Cursor оно активируется при открытии файлов по маске: *.sln, global.json, Directory.Build.props, Directory.Package.props, *.csproj и *.fsproj.
Исходный текст
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