Cursor rule
.cursor/rules/csproj.mdcCodeSpirit 项目配置规范 - 目标框架、SDK类型、集中式包管理
Cursor rules
Quality
54/100
Scores the file, not the repository.Length
448 words
20 headings · 10 code blocksRepository
56
— · pushed 134 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# csproj 项目配置规范89## 目标框架1011- **必须使用 .NET 10**: `<TargetFramework>net10.0</TargetFramework>`12- 添加或更新包时,必须与当前解决方案的包版本保持一致1314## SDK 类型选择1516| 项目类型 | SDK |17|---------|-----|18| API 服务 | `Microsoft.NET.Sdk.Web` |19| 组件库 / 类库 | `Microsoft.NET.Sdk` |20| AppHost | `Aspire.AppHost.Sdk/13.0.2` |2122## PropertyGroup 配置规范2324### 通用配置2526```xml27<PropertyGroup>28 <TargetFramework>net10.0</TargetFramework>29 <ImplicitUsings>enable</ImplicitUsings>30</PropertyGroup>31```3233### Web API 项目3435```xml36<PropertyGroup>37 <TargetFramework>net10.0</TargetFramework>38 <ImplicitUsings>enable</ImplicitUsings>39 <Nullable>disable</Nullable>40 <UserSecretsId>{生成的GUID}</UserSecretsId>41 <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>42 <DockerfileContext>..\..</DockerfileContext>43</PropertyGroup>44```4546### AppHost 项目4748```xml49<PropertyGroup>50 <OutputType>Exe</OutputType>51 <TargetFramework>net10.0</TargetFramework>52 <ImplicitUsings>enable</ImplicitUsings>53 <Nullable>enable</Nullable>54 <IsAspireHost>true</IsAspireHost>55</PropertyGroup>56```5758### 测试项目5960```xml61<PropertyGroup>62 <TargetFramework>net10.0</TargetFramework>63 <ImplicitUsings>enable</ImplicitUsings>64 <IsPackable>false</IsPackable>65</PropertyGroup>6667<ItemGroup>68 <Using Include="Xunit" />69</ItemGroup>70```7172### 需要生成文档的组件库7374```xml75<PropertyGroup>76 <GenerateDocumentationFile>true</GenerateDocumentationFile>77</PropertyGroup>78```7980## 集中式包管理(Central Package Management)8182> ✅ **重要**: 项目已启用集中式包管理,所有包版本在 `Directory.Packages.props` 中统一管理8384### 包引用规范85861. **添加新包时**:87 - 首先在 `Directory.Packages.props` 中添加 `<PackageVersion Include="PackageName" Version="x.y.z" />`88 - 然后在项目文件中添加 `<PackageReference Include="PackageName" />`(**不指定 Version**)89902. **项目文件中的包引用**:91```xml92 <!-- ✅ 正确:不指定版本,由 Directory.Packages.props 管理 -->93 <PackageReference Include="Newtonsoft.Json" />9495 <!-- ❌ 错误:不要指定版本 -->96 <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />97```98993. **版本覆盖(特殊情况)**:100 - 仅在必要时使用 `VersionOverride`,并添加注释说明原因101 - 例如:使用 `Aspire.Microsoft.EntityFrameworkCore.SqlServer` 的项目需要 EF Core 10.0.0102```xml103 <!-- 注意:Aspire.Microsoft.EntityFrameworkCore.SqlServer 13.0.2 需要 EF Core 10.0.0 -->104 <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" VersionOverride="10.0.0" />105```1061074. **查看所有包版本**:108 - 查看 `Directory.Packages.props` 文件109 - 包按功能分类组织(Aspire、EF Core、Extensions 等)110111### 核心框架包版本112113所有包版本在 `Directory.Packages.props` 中定义,主要版本如下:114115| 包类别 | 版本 |116|--------|------|117| Aspire.* (大部分) | `13.0.2` |118| Aspire.Hosting.Elasticsearch | `13.1.0` |119| Aspire.Elastic.Clients.Elasticsearch | `13.1.0` |120| Microsoft.Extensions.* | `10.0.0` |121| Microsoft.AspNetCore.* | `10.0.0` |122| Microsoft.EntityFrameworkCore.* | `9.0.9` (默认) / `10.0.0` (使用 Aspire EF Core 集成) |123| Pomelo.EntityFrameworkCore.MySql | `9.0.0` |124| OpenTelemetry.* | `1.11.1` |125| StackExchange.Redis | `2.9.32` |126| Newtonsoft.Json | `13.0.3` |127| AutoMapper | `13.0.1` |128| FluentValidation | `11.11.0` |129| Scrutor | `4.2.2` |130| LinqKit.Core | `1.2.8` |131| Polly | `8.5.2` |132133### 测试包版本134135| 包 | 版本 |136|---|------|137| Microsoft.NET.Test.Sdk | `17.13.0` |138| xunit | `2.9.3` |139| xunit.runner.visualstudio | `3.0.2` |140| Moq | `4.20.72` |141| coverlet.collector | `6.0.4` |142| Microsoft.EntityFrameworkCore.InMemory | `9.0.9` |143| FluentAssertions | `7.0.0` |144| NBomber | `6.2.0-beta.4` |145146## 项目引用路径147148- 使用相对路径 `..\..\` 格式149- 路径分隔符使用反斜杠 `\`150151### 示例152153```xml154<ItemGroup>155 <ProjectReference Include="..\..\CodeSpirit.Core\CodeSpirit.Core.csproj" />156 <ProjectReference Include="..\..\CodeSpirit.Shared\CodeSpirit.Shared.csproj" />157</ItemGroup>158```159160## 工具包配置161162对于仅作为开发工具使用的包,需添加资产限制:163164```xml165<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">166 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>167 <PrivateAssets>all</PrivateAssets>168</PackageReference>169```170171## 迁移文件夹172173API 项目如需 EF 迁移,应创建按数据库类型分离的迁移目录:174175```xml176<ItemGroup>177 <Folder Include="Data\Migrations\MySql\" />178 <Folder Include="Data\Migrations\SqlServer\" />179</ItemGroup>180```181182## 传递依赖处理183184### 避免冗余引用185186以下包通过项目引用传递可用,通常不需要显式引用:187188- **通过 `CodeSpirit.Shared` 传递**:189 - `Newtonsoft.Json`190 - `Microsoft.EntityFrameworkCore.SqlServer`191 - `Pomelo.EntityFrameworkCore.MySql`192 - `LinqKit.Core`193 - `Microsoft.EntityFrameworkCore`194 - `RabbitMQ.Client`195 - `Aspire.RabbitMQ.Client`196197- **通过 `CodeSpirit.ServiceDefaults` 传递**:198 - `Aspire.Seq`199 - `Aspire.StackExchange.Redis.DistributedCaching`200201- **通过 `FrameworkReference` 提供**:202 - `Microsoft.AspNetCore.Http.Abstractions`(.NET 10)203 - `Microsoft.AspNetCore.Mvc.Core`(.NET 10)204205如果项目确实需要这些包,应添加注释说明原因。206207## 禁止事项208209- ❌ **不要在 PackageReference 中指定 Version**(使用集中式包管理)210- ❌ 不要混用不同版本的同一包211- ❌ 不要使用 `<LangVersion>` 指定语言版本(使用框架默认)212- ❌ 不要在 PackageReference 中使用浮动版本 (如 `*`)213- ❌ 不要使用绝对路径引用项目214- ❌ 不要添加通过传递依赖已可用的包引用(除非有特殊需求)
Also in xin-lai/CodeSpirit
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| xin-lai/CodeSpirit.cursor/rules/js.mdc · 56 | Cursor rules | apidocs | 46/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/ai-development.mdc · 56 | Cursor rules | api | 46/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/all.mdc · 56 | Cursor rules | testing-strategyapi | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/amis-cards.mdc · 56 | Cursor rules | no sections | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/api-design.mdc · 56 | Cursor rules | no sections | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/controller.mdc · 56 | Cursor rules | api | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/cs.mdc · 56 | Cursor rules | no sections | 25/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/css.mdc · 56 | Cursor rules | ui | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/database.mdc · 56 | Cursor rules | no sections | 74/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/dependency-injection.mdc · 56 | Cursor rules | api | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/dto.mdc · 56 | Cursor rules | no sections | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/enum.mdc · 56 | Cursor rules | no sections | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/i18n.mdc · 56 | Cursor rules | no sections | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/naming-conventions.mdc · 56 | Cursor rules | no sections | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/package-management.mdc · 56 | Cursor rules | no sections | 74/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/performance.mdc · 56 | Cursor rules | no sections | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/project-structure.mdc · 56 | Cursor rules | api | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/security.mdc · 56 | Cursor rules | database | 54/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/service.mdc · 56 | Cursor rules | no sections | 50/100 | 3 days ago | |
| xin-lai/CodeSpirit.cursor/rules/startup-framework.mdc · 56 | Cursor rules | api | 54/100 | 3 days ago |
Diff against .cursor/rules/js.mdc Diff against .cursor/rules/ai-development.mdc Diff against .cursor/rules/all.mdc Diff against .cursor/rules/amis-cards.mdc Diff against .cursor/rules/api-design.mdc Diff against .cursor/rules/controller.mdc Diff against .cursor/rules/cs.mdc Diff against .cursor/rules/css.mdc Diff against .cursor/rules/database.mdc Diff against .cursor/rules/dependency-injection.mdc Diff against .cursor/rules/dto.mdc Diff against .cursor/rules/enum.mdc Diff against .cursor/rules/i18n.mdc Diff against .cursor/rules/naming-conventions.mdc Diff against .cursor/rules/package-management.mdc Diff against .cursor/rules/performance.mdc Diff against .cursor/rules/project-structure.mdc Diff against .cursor/rules/security.mdc Diff against .cursor/rules/service.mdc Diff against .cursor/rules/startup-framework.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
