Skip to content

Commit efe5694

Browse files
committed
Docs: Add modernization skill documentation
1 parent 8afbe8c commit efe5694

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

modernize_dotnet_build.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Skill: Modernize .NET Build & CI/CD
2+
3+
## Objective
4+
Upgrade a legacy .NET project to use Central Package Management (CPM), standard build properties, locked dependencies, and comprehensive GitHub Actions pipelines.
5+
6+
## Prerequisites
7+
* Existing .NET solution.
8+
* Access to reference configuration (e.g., `api-core`) for standard property files and rulesets.
9+
10+
## Step-by-Step Procedure
11+
12+
### 1. Clean & Standardize Configuration
13+
* **NuGet:** Clean `NuGet.Config` (add `<clear />` to prevent pollution).
14+
* **Git:** Update `.gitignore` to a modern standard (exclude IDE/editor noise).
15+
* **Documentation:** Update `README.md` with standard project structure/links.
16+
* **Legacy Removal:** Delete obsolete build scripts (e.g., `psake`, `build.bat`) and remove their references from the `.sln` file.
17+
18+
### 2. Implement Modern Build Infrastructure
19+
* **Properties:** Introduce `src/Directory.Build.props` (versioning, compiler flags) and `src/common.props` / `src/common-tests.props` (shared dependencies, rulesets).
20+
* **Central Package Management:** Create `src/Directory.Packages.props`. Move all `PackageVersion` definitions from individual `.csproj` files to this central file.
21+
* **Project Files:** Update `.csproj` files to remove explicit versions and import `common.props`.
22+
* **Analyzers:** Rename/Update ruleset files (`StyleCop.ruleset` -> `Analyzer.ruleset`) to match the standard.
23+
24+
### 3. Resolve Upgrade Issues
25+
* **Code Fixes:** Run a build (`dotnet build`). Fix compilation errors caused by upgraded dependencies (e.g., moved exception types like `ApiUsageError`).
26+
* **Static Analysis:** Address or suppress new StyleCop/Analyzer errors (e.g., `SA1402` split files, `SA16xx` documentation) to ensure a clean build. Use `Analyzer.ruleset` to suppress if necessary, or fix code structure.
27+
28+
### 4. Finalize Solution Structure
29+
* **Assets:** Update standard assets (e.g., logos) in the `assets/` folder.
30+
* **Solution File:** Add the new configuration files (`.props`, `.ruleset`, `global.json`) to the Solution Items folder in `.sln` for easy access.
31+
32+
### 5. Enforce Reproducibility
33+
* **SDK Locking:** Create `global.json` to pin the .NET SDK version (e.g., to `10.0.102` or matching valid SDK).
34+
* **Dependency Locking:** Run `dotnet restore --force-evaluate` to generate `packages.lock.json` files.
35+
36+
### 6. Establish CI/CD Pipelines (GitHub Actions)
37+
* **CI Pipeline:** Create `.github/workflows/ci.yml` for building and testing on every push/PR. Ensure it uses `global.json` and `--locked-mode`.
38+
* **Publish Pipeline:** Create `.github/workflows/publish.yml` to package and push to NuGet/GitHub Releases on tag creation.
39+
* **Reproducibility Workflow:** Create `.github/workflows/reproduce-build.yml` to verify that previous releases can be rebuilt bit-for-bit identical.

0 commit comments

Comments
 (0)