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
# GitHub Copilot Instructions — Windows Forms File-based App (FBA) Template
2
2
3
-
> Opinionated, production-ready guidance for building **.NET 10** Windows Forms apps as a **single C# file**.
3
+
> Production-ready guidance for building **.NET 10** WinForms apps in a **single C# file**.
4
+
> **Note:** Per on-device verification, this template **requires the two-step apartment state init (`Unknown` → `STA`)**.
4
5
5
6
---
6
7
7
-
## 1) Project Overview
8
+
## 1) Overview
8
9
9
-
Author a full Windows Forms desktop app using the **File-based App (FBA)** model: keep build/runtime directives at the top of one `.cs` file; put top-level program code first; types follow.
10
+
Build a full WinForms desktop app with the **File-based App (FBA)** model: directives at the top of one `.cs` file, top-level bootstrapping first, types below.
10
11
11
12
---
12
13
13
14
## 2) FBA Directives (Windows-only GUI)
14
15
15
16
```csharp
16
-
// Shebang optional for Windows-only GUI apps
17
+
// Shebang optional for Windows-only apps
17
18
18
19
#:sdk Microsoft.NET.Sdk
19
20
#:property OutputType=WinExe
20
21
#:property TargetFramework=net10.0-windows
21
22
#:property UseWindowsForms=True
22
23
#:property UseWPF=False
23
-
#:property PublishAot=False// WinForms is not AOT-compatible
24
+
#:property PublishAot=False
24
25
#:property Nullable=enable
25
26
```
26
27
27
28
**Notes**
28
29
29
-
*Prefer`net10.0-windows` to light up Windows-only APIs.
30
-
* Keep directives at the very top.
31
-
*No packages are required to start; pin any added packages with exact versions.
*[ ] Top-level code **before** types; DI wired via `Host.CreateApplicationBuilder`
226
-
*[ ]`ApplicationContext` for lifetime; main form centered; controls laid out with Dock/Anchor
227
-
*[ ] Long operations off UI thread; safe marshaling back to UI
228
-
*[ ] Accessibility, keyboard navigation, and proper error feedback
229
-
*[ ] Single-file FBA; no unnecessary packages; pinned versions if any are added
222
+
*[ ]**Apartment state set: `Unknown` → `STA`**
223
+
*[ ] Top-level bootstrapping before types; DI via `Host.CreateApplicationBuilder`
224
+
*[ ]`ApplicationContext` for lifetime; centered window; Dock/Anchor layout
225
+
*[ ] Long work off UI thread; safe marshaling back
226
+
*[ ] Accessibilityand clear error feedback
227
+
*[ ] Single-file FBA; exact package versions pinned if any are added
230
228
231
229
---
232
230
233
-
##17) MCP Integration (NuGet & Docs)
231
+
### Callout
234
232
235
-
***Never guess package versions.** If you add packages (logging, settings, etc.), resolve exact versions via your **`nuget` MCP server** and pin them with `#:package [email protected]`.
236
-
* Use **`microsoft_learn` MCP** to verify current WinForms DPI, accessibility, and deployment guidance.
233
+
Your field result matters. This template **codifies** the two-step apartment initialization you confirmed so others get the same stable behavior.
0 commit comments