Skip to content

Commit ecdbc0b

Browse files
Add copilot instructions (#1405)
* Add copilot instructions * Update .github/copilot-instructions.md Co-authored-by: Matt Thalman <[email protected]> * Fix linter issues and respond to code review feedback --------- Co-authored-by: Matt Thalman <[email protected]>
1 parent 22dcf69 commit ecdbc0b

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

.github/copilot-instructions.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# .NET Source Build Reference Packages - Copilot Instructions
2+
3+
This file contains AI-specific guidance for working with this repository.
4+
All general documentation is maintained in the [README.md](../README.md) to avoid duplication.
5+
6+
## Critical Safety Rules
7+
8+
### Absolute Prohibitions
9+
10+
- **NEVER** modify files inside `src/externalPackages/src/` (these are git submodules)
11+
- **NEVER** delete or recreate `Customizations.props` or `Customizations.cs` files
12+
- **NEVER** suggest adding preview/RC packages
13+
- **NEVER** ignore build failures in `./build.sh -sb`
14+
15+
### Before Making Changes
16+
17+
- **ALWAYS** check if a package has existing customizations before regenerating
18+
- **ALWAYS** validate commands work on Linux (primary platform for source-build)
19+
- **ALWAYS** preserve intentional code comments explaining manual fixes
20+
21+
## Workflow Patterns
22+
23+
### When User Asks to "Add a Package"
24+
25+
1. Determine package type first: External, Reference, Targeting, or Text-only
26+
2. For Reference packages: Use `./generate.sh --package name,version`
27+
3. For External packages: Requires submodule + project creation + patches1
28+
4. Check README for detailed workflows
29+
30+
### When Regenerating Packages
31+
32+
```bash
33+
# Check for existing customizations first
34+
find src/referencePackages/src/package.name/version -name "Customizations.*"
35+
```
36+
37+
- If customizations exist, preserve them during regeneration
38+
- The generate script will preserve them
39+
40+
### When Build Fails
41+
42+
1. Try building individual package: `./build.sh -sb --projects /full/path/to/package.csproj`
43+
2. Check for compilation errors that need `Customizations.props` (NoWarn entries)
44+
3. Look for API issues that need `Customizations.cs` (partial class additions)
45+
4. Always add explanatory comments for manual fixes needed in the generated source files outside of Customizations files
46+
47+
## Decision Support
48+
49+
### Customizations.props vs Customizations.cs
50+
51+
- **Customizations.props**: MSBuild properties, NoWarn suppressions, additional source files
52+
- **Customizations.cs**: Additional types, members for partial classes, conditional compilation
53+
54+
### External Package Changes
55+
56+
- Always create patches via `extract-patches.sh` - never suggest direct file edits
57+
- Patches live in `src/externalPackages/patches/<component>/`
58+
- Test patches with `git am` before suggesting
59+
60+
## Validation Checklist
61+
62+
After any package changes:
63+
64+
- [ ] `./build.sh -sb` succeeds
65+
- [ ] Check `artifacts/packages/*` for expected output
66+
- [ ] Verify no new files in submodule directories
67+
- [ ] Confirm Customizations files preserved if they existed
68+
69+
## 🔗 References
70+
71+
- All build commands and detailed processes are in the [README.md](../README.md)
72+
- Generator issues: [docs/known_generator_issues.md](../docs/known_generator_issues.md)

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# .NET Source Build Assets
22

33
This repository contains source, tools, and infrastructure for auxilary packages required to [build .NET from source](https://github.com/dotnet/source-build).
4+
This repository is often referred to as `SBRP`.
45

56
This repo supports the following package types:
67

@@ -44,6 +45,7 @@ to .NET. The following sections describe how to add/upgrade the various types of
4445
### External
4546

4647
#### Adding a New External Component
48+
4749
1. Add the repo as a submodule to `./src/externalPackages/src`
4850

4951
```bash
@@ -52,7 +54,7 @@ to .NET. The following sections describe how to add/upgrade the various types of
5254
```
5355

5456
1. Define a [project](src/externalPackages/projects) for the new component.
55-
The project is responsible for building the submodule with the appropriate configuration for source build.
57+
The project is responsible for building the submodule with the appropriate configuration for source build.
5658
See the [existing projects](src/externalPackages/projects) for examples.
5759

5860
1. [Build](#building) locally and resolve any build errors.
@@ -109,7 +111,7 @@ the maintenance burden when [updating a component to a newer version](#updating-
109111
110112
1. From the root directory of the submodule, run [extract-patches.sh](src/externalPackages/patches/extract-patches.sh)/[extract-patches.ps1](src/externalPackages/patches/extract-patches.ps1).
111113
The script will prepare a patch based on the base sha of the submodule and the latest committed changes.
112-
The patch will be added to patches/<component>/*.patch
114+
The patch will be added to `patches/<component>/*.patch`
113115
114116
1. To apply a patch, or multiple patches, use `git am` while inside the submodule directory.
115117
For example, to apply *all* `humanizer` patches:

0 commit comments

Comments
 (0)