Skip to content

Commit 1918338

Browse files
authored
Merge pull request #645 from dotnet/add-copilot
Add Copilot for .NET MAUI samples
2 parents 0de31c7 + 241b1a6 commit 1918338

File tree

3 files changed

+292
-0
lines changed

3 files changed

+292
-0
lines changed

.github/copilot-setup-steps.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16+
copilot-setup-steps:
17+
runs-on: ubuntu-latest
18+
19+
# Set the permissions to the lowest permissions possible needed for your steps.
20+
# Copilot will be given its own token for its operations.
21+
permissions:
22+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
23+
contents: read
24+
25+
# You can define any steps you want, and they will run before the agent starts.
26+
# If you do not check out your code, Copilot will do this for you.
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup .NET 9 SDK
32+
uses: actions/setup-dotnet@v4
33+
with:
34+
dotnet-version: '9.0.x'
35+
36+
- name: Install MAUI Android workload
37+
run: |
38+
dotnet workload install maui-android
39+
dotnet workload list
40+
41+
- name: Restore .NET dependencies
42+
run: dotnet restore src/MauiAppCreAItor/MauiAppCreAItor.csproj
43+
44+
- name: Verify .NET installation
45+
run: |
46+
dotnet --version
47+
dotnet --info
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
---
2+
applyTo: '**'
3+
---
4+
5+
# GitHub Copilot Development Environment Instructions
6+
7+
This document provides specific guidance for GitHub Copilot when working on the .NET MAUI Samples repository. It serves as context for understanding the project structure, development workflow, and best practices.
8+
9+
## Repository Overview
10+
11+
This repository contains **sample applications and demonstrations** for **.NET MAUI** (Multi-platform App UI), a cross-platform framework for creating mobile and desktop applications with C# and XAML. The samples showcase various features, controls, and capabilities of the .NET MAUI framework across Android, iOS, iPadOS, macOS, and Windows platforms.
12+
13+
### Key Technologies
14+
- **.NET SDK** - Various versions depending on the sample:
15+
- **8.0 folder**: Samples targeting .NET 8
16+
- **9.0 folder**: Samples targeting .NET 9
17+
- **10.0 folder**: Samples targeting .NET 10
18+
- etc.
19+
- **C#** and **XAML** for application development
20+
- **MSBuild** for building individual samples
21+
- **Various testing frameworks** including NUnit and Appium for UI testing samples
22+
23+
## Development Environment Setup
24+
25+
### Prerequisites
26+
27+
Before working with .NET MAUI samples, ensure your development environment is properly configured according to the official documentation:
28+
29+
1. **Follow the official .NET MAUI installation guide:**
30+
- Visit [Install .NET MAUI](https://docs.microsoft.com/dotnet/maui/get-started/installation) for comprehensive setup instructions
31+
- Install the required .NET SDK version (8.0, 9.0, or 10.0 depending on the sample)
32+
33+
2. **Verify installation:**
34+
```powershell
35+
dotnet --version
36+
dotnet workload list
37+
```
38+
39+
### Initial Repository Setup
40+
41+
1. **Clone and navigate to repository:**
42+
```powershell
43+
git clone https://github.com/dotnet/maui-samples.git
44+
cd maui-samples
45+
```
46+
47+
2. **Choose and navigate to the appropriate sample:**
48+
```powershell
49+
# For .NET 10 samples
50+
cd 10.0/UserInterface/ControlGallery
51+
52+
# For .NET 9 samples
53+
cd 9.0/Apps/Calculator
54+
55+
# For .NET 8 samples
56+
cd 8.0/Apps/WeatherTwentyOne
57+
```
58+
59+
3. **Build and run the sample:**
60+
```powershell
61+
dotnet build
62+
dotnet run
63+
```
64+
65+
## Project Structure
66+
67+
### Important Directories
68+
- `8.0/` - Samples targeting .NET 8
69+
- `9.0/` - Samples targeting .NET 9
70+
- `10.0/` - Samples targeting .NET 10
71+
- `eng/` - Build engineering and tooling
72+
- `.github/` - GitHub workflows and configuration
73+
- `Images/` - Shared images used across samples
74+
- `Upgrading/` - Migration examples from Xamarin.Forms to .NET MAUI
75+
76+
### Platform-Specific Code Organization
77+
- **Android** specific code is inside folders labeled `Android`
78+
- **iOS** specific code is inside folders labeled `iOS`
79+
- **MacCatalyst** specific code is inside folders named `MacCatalyst`
80+
- **Windows** specific code is inside folders named `Windows`
81+
82+
### Platform-Specific File Extensions
83+
- Files with `.windows.cs` will only compile for the Windows TFM
84+
- Files with `.android.cs` will only compile for the Android TFM
85+
- Files with `.ios.cs` will only compile for the iOS and MacCatalyst TFM
86+
- Files with `MacCatalyst.cs` will only compile for the MacCatalyst TFM
87+
88+
### Sample Categories
89+
```
90+
├── Apps/ - Complete sample applications
91+
│ ├── Calculator/
92+
│ ├── WeatherTwentyOne/
93+
│ ├── PointOfSale/
94+
│ ├── WhatToEat/
95+
│ └── ...
96+
├── UserInterface/ - UI controls and layout demos
97+
│ ├── ControlGallery/
98+
│ ├── Views/
99+
│ ├── Layouts/
100+
│ └── ...
101+
├── Navigation/ - Navigation pattern samples
102+
├── Data/ - Data access and storage samples
103+
├── WebServices/ - REST API and web service samples
104+
├── UITesting/ - UI testing with Appium samples
105+
├── Fundamentals/ - Core concepts like data binding, MVVM
106+
├── PlatformIntegration/ - Platform-specific features
107+
├── XAML/ - XAML markup and styling samples
108+
├── SkiaSharp/ - SkiaSharp graphics samples
109+
├── Tutorials/ - Step-by-step learning samples
110+
├── Packaging/ - NuGet packaging and MSBuild samples
111+
├── Sensors/ - Device sensor integration samples
112+
└── Animations/ - Animation and visual effects samples
113+
```
114+
115+
## Development Workflow
116+
117+
### Creating New Samples
118+
119+
When creating new .NET MAUI samples, use the `dotnet new maui` template:
120+
121+
```powershell
122+
# Create a new .NET MAUI sample
123+
dotnet new maui -n SampleName
124+
125+
# Navigate to the sample directory
126+
cd SampleName
127+
```
128+
129+
### Building Individual Samples
130+
131+
Each sample is self-contained and can be built independently:
132+
133+
```powershell
134+
# Navigate to a specific sample
135+
cd 10.0/Apps/Calculator
136+
137+
# Build the sample
138+
dotnet build
139+
140+
# Run the sample (if supported on current platform)
141+
dotnet run
142+
```
143+
144+
### Sample Structure
145+
146+
Most samples follow this structure:
147+
```
148+
SampleName/
149+
├── SampleName.sln - Solution file
150+
├── SampleName/ - Main project folder
151+
├── Screenshots/ - Sample screenshots (PNG format)
152+
└── README.md - Sample documentation
153+
```
154+
155+
## Sample Requirements
156+
157+
### Required Files and Structure
158+
159+
Every sample must include:
160+
161+
1. **README.md** - Documentation file with YAML front matter header
162+
2. **Screenshots folder** - Empty folder for future screenshots
163+
3. **Project files** - Standard .NET MAUI project structure
164+
4. **Solution file** - `.sln` file for the sample
165+
166+
### README.md Format
167+
168+
Each sample's README.md must follow this format:
169+
170+
```markdown
171+
---
172+
name: .NET MAUI - Sample Name
173+
description: Brief description of what the sample demonstrates.
174+
page_type: sample
175+
languages:
176+
- csharp
177+
- xaml
178+
products:
179+
- dotnet-maui
180+
urlFragment: category-samplename
181+
---
182+
183+
# Sample Name
184+
185+
Detailed description of the sample, its purpose, and key features demonstrated.
186+
187+
```
188+
189+
**Key elements:**
190+
- **YAML front matter** with metadata (name, description, page_type, languages, products, urlFragment)
191+
- **Clear sample name** in the `name` field prefixed with ".NET MAUI - "
192+
- **Concise description** explaining what the sample demonstrates
193+
- **URL fragment** following the pattern: `category-samplename` (lowercase, hyphenated)
194+
- **Detailed content** explaining the sample's purpose and features
195+
196+
### Screenshots Requirements
197+
198+
- Create an empty `Screenshots/` folder in each sample directory
199+
- Screenshots will be added later by maintainers
200+
201+
### Testing and Debugging
202+
203+
#### UI Testing Guidelines
204+
205+
Some samples include UI testing with Appium and NUnit. When working with UI testing samples:
206+
207+
1. **Navigate to the UI testing sample:**
208+
```powershell
209+
cd 10.0/UITesting/BasicAppiumNunitSample
210+
```
211+
212+
2. **Build the test projects:**
213+
```powershell
214+
dotnet build UITests.Shared/UITests.Shared.csproj
215+
```
216+
217+
3. **Run platform-specific tests:**
218+
```powershell
219+
# For Android
220+
dotnet build UITests.Android/UITests.Android.csproj
221+
# For iOS (on macOS)
222+
dotnet build UITests.iOS/UITests.iOS.csproj
223+
```
224+
225+
## Additional Resources
226+
227+
- [.NET MAUI Documentation](https://docs.microsoft.com/dotnet/maui)
228+
- [.NET MAUI GitHub Repository](https://github.com/dotnet/maui)
229+
- [Samples Browser](https://docs.microsoft.com/samples/browse/?expanded=dotnet&products=dotnet-maui)
230+
231+
---
232+
233+
**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.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
mode: agent
3+
---
4+
I would like to update the 9.0 samples to the latest .NET 10 version. Make sure to use the Microsoft Learn MCP. Please follow these steps:
5+
6+
1. **Create a folder called 10.0**: Create a new folder named `10.0` in the root directory of the repository.
7+
2. **Copy the 9.0 samples**: Copy all the contents from the `9.0` folder into the newly created `10.0` folder. Don't copy bin and obj if present.
8+
3. **Update Target Framework**: Change the target framework in the project files from `net9.0` to `net10.0`.
9+
4. **Update SupportedOSPlatformVersion**: Update SupportedOSPlatformVersion to their latest versions compatible with .NET 10.
10+
5. **Update Deprecated APIs**: Review and update any deprecated APIs or obsolete methods to use the latest recommended alternatives in .NET 10. Address any compiler warnings and follow guidance from Microsoft Learn documentation.
11+
6. **Address Build Warnings**: Resolve any build warnings that appear during compilation, referring to Microsoft Learn for best practices and updated guidance.
12+
7. **Test the Samples**: Build each sample to ensure they compile with the newest version and run without warnings.

0 commit comments

Comments
 (0)