You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+90-53Lines changed: 90 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
description: "Guidance for GitHub Copilot when working on the .NET MAUI repository."
3
+
date: 2025-10-30
4
+
---
5
+
1
6
# GitHub Copilot Development Environment Instructions
2
7
3
8
This document provides specific guidance for GitHub Copilot when working on the .NET MAUI repository. It serves as context for understanding the project structure, development workflow, and best practices.
@@ -7,14 +12,24 @@ This document provides specific guidance for GitHub Copilot when working on the
7
12
**.NET MAUI** is a cross-platform framework for creating mobile and desktop applications with C# and XAML. This repository contains the core framework code that enables development for Android, iOS, iPadOS, macOS, and Windows from a single shared codebase.
8
13
9
14
### Key Technologies
10
-
-**.NET SDK** - Version depends on the branch:
11
-
-**main branch**: Use the latest stable version of .NET to build
15
+
16
+
-**.NET SDK** - Version is **ALWAYS** defined in `global.json` at repository root
17
+
-**main branch**: Use the latest stable version of .NET to build (currently .NET 10)
12
18
-**net10.0 branch**: Use the latest .NET 10 SDK
13
19
-**etc.**: Each feature branch correlates to its respective .NET version
14
20
-**C#** and **XAML** for application development
15
21
-**Cake build system** for compilation and packaging
16
22
-**MSBuild** with custom build tasks
17
-
-**xUnit** for testing
23
+
-**xUnit + NUnit** for testing (xUnit for unit tests, NUnit for UI tests)
24
+
25
+
**🚨 CRITICAL**: Before any build operation, verify .NET SDK version:
26
+
```bash
27
+
# Check required version
28
+
cat global.json | grep -A 1 '"dotnet"'
29
+
30
+
# Verify installed version matches
31
+
dotnet --version
32
+
```
18
33
19
34
## Development Environment Setup
20
35
@@ -31,6 +46,8 @@ For .NET installation on Linux, follow the official Microsoft documentation:
31
46
32
47
### Initial Repository Setup
33
48
49
+
**🚀 Mandatory Setup Sequence** - Run these in exact order:
50
+
34
51
1.**Clone and navigate to repository:**
35
52
```bash
36
53
git clone https://github.com/dotnet/maui.git
@@ -43,6 +60,15 @@ For .NET installation on Linux, follow the official Microsoft documentation:
43
60
dotnet build ./Microsoft.Maui.BuildTasks.slnf
44
61
```
45
62
63
+
**⚠️ FAILURE RECOVERY**: If restore or build fails:
64
+
```bash
65
+
# Clean and retry
66
+
dotnet clean
67
+
rm -rf bin/ obj/
68
+
dotnet tool restore --force
69
+
dotnet build ./Microsoft.Maui.BuildTasks.slnf --verbosity normal
70
+
```
71
+
46
72
## Project Structure
47
73
48
74
### Important Directories
@@ -68,14 +94,14 @@ For .NET installation on Linux, follow the official Microsoft documentation:
[Category(UITestCategories.Layout)] // or appropriate category
143
-
publicvoidTestMethodName()
144
-
{
145
-
App.WaitForElement("AutomationId");
146
-
App.Tap("AutomationId");
147
-
// Add assertions to verify expected behavior
148
-
}
149
-
}
150
-
```
151
-
152
-
**Before committing UI tests:**
153
-
- Compile both the HostApp project and TestCases.Shared.Tests project to ensure no build errors
154
-
- Verify AutomationId references match between XAML and test code
155
-
- Ensure tests follow the established naming and inheritance patterns
156
-
- There should be only one `[Category]` attribute per test, pick the most appropriate one
141
+
**Key reminders:**
142
+
- UI tests require code in TWO projects: `TestCases.HostApp/Issues/` (UI page) and `TestCases.Shared.Tests/Tests/Issues/` (test implementation)
143
+
- Avoid platform-specific directives (`#if ANDROID`, `#if IOS`, etc.) unless absolutely necessary - tests should run on all applicable platforms by default
144
+
- When a new UI test category is added to `UITestCategories.cs`, also update `ui-tests.yml` to include the new category
157
145
158
-
IMPORTANT NOTE: When a new UI test category is added to `UITestCategories.cs`, we need to also update the `ui-tests.yml` to include this new category. Make sure to detect this in your reviews.
146
+
**For comprehensive UI testing guidance**, see:
147
+
-[UI Testing Guide](../docs/UITesting-Guide.md) - Complete guide with prerequisites, examples, and best practices
148
+
-[UI Testing Architecture](../docs/design/UITesting-Architecture.md) - CI/CD integration and architecture details
149
+
-[Path-specific UI Test Instructions](instructions/uitests.instructions.md) - Detailed instructions for test files
159
150
160
151
### Code Formatting
161
152
@@ -266,14 +257,60 @@ All PRs are required to have this at the top of the description:
266
257
267
258
Always put that at the top, without the block quotes. Without it, the users will NOT be able to try the PR and your work will have been in vain!
268
259
260
+
## Troubleshooting
261
+
262
+
### Common Build Issues
263
+
264
+
**Issue: "Build tasks not found"**
265
+
```bash
266
+
# Solution: Rebuild build tasks
267
+
dotnet clean ./Microsoft.Maui.BuildTasks.slnf
268
+
dotnet build ./Microsoft.Maui.BuildTasks.slnf
269
+
```
270
+
271
+
**Issue: "Dependency version conflicts"**
272
+
```bash
273
+
# Solution: Full clean and restore
274
+
dotnet clean Microsoft.Maui.sln
275
+
rm -rf bin/ obj/
276
+
dotnet restore Microsoft.Maui.sln --force
277
+
```
278
+
279
+
**Issue: "Android SDK not found"**
280
+
```bash
281
+
# Solution: Check and install Android components
282
+
android # Opens Android SDK Manager
283
+
# Or set environment variable: export ANDROID_HOME=/path/to/android-sdk
284
+
```
285
+
286
+
**Issue: "PublicAPI analyzer failures"**
287
+
```bash
288
+
# Solution: Use format analyzers first
289
+
dotnet format analyzers Microsoft.Maui.sln
290
+
# If still failing, check build output for required API entries
291
+
```
292
+
293
+
### Platform-Specific Troubleshooting
294
+
295
+
**iOS/Mac Build Issues:**
296
+
- Verify Xcode command line tools: `xcode-select --install`
297
+
- Check Xcode version compatibility with .NET MAUI version
298
+
- Ensure provisioning profiles are current (for device testing)
299
+
300
+
**Android Build Issues:**
301
+
- Verify OpenJDK 17 installation: `java -version`
302
+
- Check ANDROID_HOME environment variable
303
+
- Update Android SDK components via Android SDK Manager
304
+
305
+
**Windows Build Issues:**
306
+
- Ensure Windows SDK is installed
307
+
- Verify Visual Studio workloads include .NET MAUI development
308
+
- Check for missing NuGet packages: `dotnet restore --force`
**Note for Future Updates:** This document should be expanded as new development patterns, tools, or workflows are discovered. Add sections for specific scenarios, debugging techniques, or tooling as they become relevant to the development process.
0 commit comments