RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Copilot instructions/dotnet/maui

Copilot instructions

.github/instructions/templates.instructions.md
Copilot instructions

Quality

92/100

Scores the file, not the repository.

Length

407 words

9 headings · 3 code blocks

Repository

23k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
dotnet/maui/.github/instructions/templates.instructions.mdRawGitHub
1---
2applyTo: "src/Templates/**"
3---
4 
5# Working with .NET MAUI Templates
6 
7## 1. Overview
8 
9When modifying files in the `src/Templates/` directory, you must follow special template semantics and conventions to ensure the templates work correctly when users create new projects. This guide covers conditional compilation directives, naming conventions, file exclusions, and testing procedures.
10 
11## 2. Conditional Compilation
12 
13Templates use special comment markers to control how preprocessor directives are processed during template instantiation.
14 
15### Build-Time Directives (Platform-Specific)
16 
17Platform-specific `#if` directives (like `#if WINDOWS`, `#if ANDROID`, `#if IOS`, `#if MACCATALYST`) must be wrapped with `//-:cnd:noEmit` and `//+:cnd:noEmit` markers:
18 
19```csharp
20//-:cnd:noEmit
21#if WINDOWS
22 // Windows-specific code
23#endif
24//+:cnd:noEmit
25```
26 
27**Why?** These markers tell the template engine to preserve these directives in the generated code exactly as-is, so they will be evaluated at compile-time when the user builds their project.
28 
29**Examples:**
30```csharp
31//-:cnd:noEmit
32#if DEBUG
33 builder.Logging.AddDebug();
34#endif
35//+:cnd:noEmit
36 
37//-:cnd:noEmit
38#if IOS || MACCATALYST
39 handlers.AddHandler<CollectionView, CollectionViewHandler2>();
40#endif
41//+:cnd:noEmit
42 
43//-:cnd:noEmit
44#if WINDOWS
45 Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping(
46 "KeyboardAccessibleCollectionView",
47 (handler, view) => { /* ... */ });
48#endif
49//+:cnd:noEmit
50```
51 
52### Template-Time Directives (Template Parameters)
53 
54Template parameter directives (like `#if (IncludeSampleContent)`) do NOT use the `//-:cnd:noEmit` markers:
55 
56```csharp
57#if (IncludeSampleContent)
58using CommunityToolkit.Maui;
59#endif
60```
61 
62**Why?** These directives are evaluated when the template is instantiated (when user runs `dotnet new maui`), not when the code is compiled.
63 
64## 3. Naming and Placeholders
65 
66- Template project names use placeholders like `MauiApp._1` which get replaced with the user's actual project name
67- Namespaces follow the same pattern: `namespace MauiApp._1;`
68- These will be transformed to the user's chosen project name during template instantiation
69 
70## 4. Files to Avoid Editing
71 
72Never modify auto-generated files in templates:
73- `cgmanifest.json` - Auto-generated component governance manifest
74- `templatestrings.json` - Auto-generated localization file
75 
76These files are regenerated during the build process and should not be manually edited.
77 
78## 5. Testing and Verification
79 
80When making changes to templates:
811. Build the template project: `dotnet build src/Templates/src/Microsoft.Maui.Templates.csproj`
822. For comprehensive testing, use the `build.ps1` script in the Templates directory to pack, install, and test the template
833. Verify the generated project compiles for all target platforms
84 
85## 6. Quick Reference Table
86 
87| Directive Type | Wrapper Needed | Example |
88| --- | --- | --- |
89| Platform-specific (`#if WINDOWS`, `#if ANDROID`, etc.) | ✅ Yes - use `//-:cnd:noEmit` | Build-time platform detection |
90| Debug mode (`#if DEBUG`) | ✅ Yes - use `//-:cnd:noEmit` | Build configuration |
91| Template parameters (`#if (IncludeSampleContent)`) | ❌ No | Template instantiation options |
92 

Commands it names

  • dotnet new maui
  • dotnet build src/Templates/src/Microsoft.Maui.Templates.csproj

Sections

  • Working with .NET MAUI Templates
  • 1. Overview
  • 2. Conditional Compilation
  • Build-Time Directives (Platform-Specific)
  • Template-Time Directives (Template Parameters)
  • 3. Naming and Placeholders
  • 4. Files to Avoid Editing
  • 5. Testing and Verification
  • 6. Quick Reference Table

What it covers

buildtestcode-stylearchitecturedo-not

Stack — with the evidence

csharp

(1.00)

dotnet

(1.00)

swift

(0.60)

github-actions

(0.60)

Glob targeting

  • src/Templates/**

Format

Copilot instructions

Two layers: one always-on repo file, plus optional glob-scoped instruction files. Lives under .github/ rather than the repo root, which is the tell that it is aimed at the GitHub platform surface as much as the editor.

What the corpus says about it

Repository

Owner
dotnet
Language
—
License
—
Archived
no

All configs in this repo

Also in dotnet/maui

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
dotnet/maui.github/instructions/collectionview-handler-detection.instructions.md · 23kCopilot instructionscsharpdotnet+2stylegitdo-not73/1003 days ago
dotnet/maui.github/copilot-instructions.md · 23kCopilot instructionscsharpdotnet+2setuptestlint-formatstyle+676/1003 days ago
dotnet/maui.github/instructions/android.instructions.md · 23kCopilot instructionscsharpdotnet+2buildstyle70/1003 days ago
dotnet/maui.github/instructions/ci-copilot-pipeline-security.instructions.md · 23kCopilot instructionscsharpdotnet+2gitsecuritydeploymentdo-not+176/1003 days ago
dotnet/maui.github/instructions/collectionview-android.instructions.md · 23kCopilot instructionscsharpdotnet+2stylearchperformanceagent-behaviour52/1003 days ago
dotnet/maui.github/instructions/collectionview-ios.instructions.md · 23kCopilot instructionscsharpdotnet+2styleperformance48/1003 days ago
dotnet/maui.github/instructions/collectionview-windows.instructions.md · 23kCopilot instructionscsharpdotnet+2stylearch52/1003 days ago
dotnet/maui.github/instructions/handler-patterns.instructions.md · 23kCopilot instructionscsharpdotnet+2styledo-not55/1003 days ago
dotnet/maui.github/instructions/helix-device-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupbuildtestarch74/1003 days ago
dotnet/maui.github/instructions/integration-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupteststyledo-not92/1003 days ago
dotnet/maui.github/instructions/layout-system.instructions.md · 23kCopilot instructionscsharpdotnet+2archapiperformancedo-not55/1003 days ago
dotnet/maui.github/instructions/performance-hotpaths.instructions.md · 23kCopilot instructionscsharpdotnet+2styleperformancedo-not55/1003 days ago
dotnet/maui.github/instructions/public-api.instructions.md · 23kCopilot instructionscsharpdotnet+2apido-not59/1003 days ago
dotnet/maui.github/instructions/safe-area-ios.instructions.md · 23kCopilot instructionscsharpdotnet+2stylegit43/1003 days ago
dotnet/maui.github/instructions/sandbox.instructions.md · 23kCopilot instructionscsharpdotnet+2buildteststyletesting-strategy+481/1003 days ago
dotnet/maui.github/instructions/threading-async.instructions.md · 23kCopilot instructionscsharpdotnet+2styleui48/1003 days ago
dotnet/maui.github/instructions/uitests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupbuildteststyle+579/1003 days ago
dotnet/maui.github/instructions/xaml-unittests.instructions.md · 23kCopilot instructionscsharpdotnet+2teststyledocs70/1003 days ago
Diff against .github/instructions/collectionview-handler-detection.instructions.md Diff against .github/copilot-instructions.md Diff against .github/instructions/android.instructions.md Diff against .github/instructions/ci-copilot-pipeline-security.instructions.md Diff against .github/instructions/collectionview-android.instructions.md Diff against .github/instructions/collectionview-ios.instructions.md Diff against .github/instructions/collectionview-windows.instructions.md Diff against .github/instructions/handler-patterns.instructions.md Diff against .github/instructions/helix-device-tests.instructions.md Diff against .github/instructions/integration-tests.instructions.md Diff against .github/instructions/layout-system.instructions.md Diff against .github/instructions/performance-hotpaths.instructions.md Diff against .github/instructions/public-api.instructions.md Diff against .github/instructions/safe-area-ios.instructions.md Diff against .github/instructions/sandbox.instructions.md Diff against .github/instructions/threading-async.instructions.md Diff against .github/instructions/uitests.instructions.md Diff against .github/instructions/xaml-unittests.instructions.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
dotnet/roslyn.github/instructions/Compiler.instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+399/1003 days ago
dotnet/roslyn.github/copilot-instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+397/1003 days ago
ardalis/CleanArchitecture.github/copilot-instructions.md · 18kCopilot instructionscsharpdotnet+1buildteststylearch+496/1003 days ago
dotnet/maui.github/instructions/integration-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupteststyledo-not92/1003 days ago
we-promise/sure.github/copilot-instructions.md · 9.3kCopilot instructionsrubyrails+13setuptestlint-formatstyle+1088/1002 days ago
microsoft/WSL.github/copilot-instructions.md · 33kCopilot instructionscsharpcpp+2setupbuildtestlint-format+788/1003 days ago
PowerShell/PowerShell.github/instructions/start-native-execution.instructions.md · 55kCopilot instructionscsharpdotnet+1buildstylearchgit+186/1003 days ago
hackiftekhar/IQKeyboardManager.github/copilot-instructions.md · 17kCopilot instructionsswiftsetupbuildtestarch+585/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack