|
| 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) |
0 commit comments