mit einem Klick
building-code
// Instructions for restoring and building the WinForms repository. Use when asked how to restore NuGet packages, build the full solution, build a single project, create packages, or troubleshoot build errors.
// Instructions for restoring and building the WinForms repository. Use when asked how to restore NuGet packages, build the full solution, build a single project, create packages, or troubleshoot build errors.
Instructions for downloading and installing .NET preview runtime versions required by the WinForms repository. Use when test executables fail with "framework not found" errors or when a specific .NET preview runtime version needs to be installed.
Instructions for running unit tests, integration tests, and individual tests in the WinForms repository. Use this when asked how to run tests, filter them, use Visual Studio workflows, or troubleshoot test failures.
Instructions for modernizing and refactoring existing C# / VB.NET code files. Use when asked to refactor, modernize, clean up, review, or improve existing source files in this repository. Covers upgrading to C# 14 / .NET 10 idioms, comment quality, spelling and grammar fixes, XML documentation, and readability improvements.
C# and .NET coding standards for generating new code files. Use when creating new classes, methods, controls, tests, or any new C# / VB source files in this repository. Covers C# 14 / .NET 10 patterns, naming, formatting, XML docs, WinForms conventions, and performance idioms.
Instructions for writing unit tests for Graphics, Bitmap, GraphicsPath, and Font rendering APIs in System.Drawing. Covers bitmap-based verification, integer/float overload testing, version-guarded test blocks, and FluentAssertions patterns for path-point validation.
Instructions for adding new public APIs (properties, methods, events, delegates) to existing WinForms controls or components. Covers API issue tracking, PublicAPI file maintenance, property/event conventions, CodeDOM serialization, design-time attributes, and XML documentation.
| name | building-code |
| description | Instructions for restoring and building the WinForms repository. Use when asked how to restore NuGet packages, build the full solution, build a single project, create packages, or troubleshoot build errors. |
| metadata | {"author":"dotnet-winforms","version":"1.0"} |
build.sh
instead of build.cmd / Restore.cmd.WinForms.vsconfig for required workloads.global.json) is used automatically by
build.cmd and Restore.cmd. You do not need a machine-wide SDK install
for command-line builds.Restoring downloads the repo-local SDK and all NuGet packages.
.\Restore.cmd
Under the hood this runs:
eng\common\Build.ps1 -NativeToolsOnMachine -restore
You can pass any extra Build.ps1 flags after Restore.cmd, e.g.
.\Restore.cmd -configuration Release.
.\build.cmd
This restores and builds Winforms.sln in Debug|Any CPU by default.
Under the hood this runs:
eng\common\Build.ps1 -NativeToolsOnMachine -restore -build -bl
| Flag | Short | Description |
|---|---|---|
-configuration <Debug|Release> | -c | Build configuration (default: Debug) |
-platform <x86|x64|Any CPU> | Platform (default: Any CPU) | |
-restore | -r | Restore only |
-build | -b | Build only (skip restore if already done) |
-rebuild | Clean + build | |
-clean | Delete build artifacts | |
-pack | Create NuGet packages (Microsoft.Private.Winforms) | |
-bl / -binaryLog | Emit artifacts\log\Debug\Build.binlog | |
-ci | CI mode (stricter warnings, signing, etc.) | |
-test | -t | Build and run unit tests |
-integrationTest | Build and run integration / functional tests |
# Release build
.\build.cmd -configuration Release
# Build and run unit tests
.\build.cmd -test
# Create NuGet package
.\build.cmd -pack
Prefer rebuilding just the project(s) with recent changes by using the
standard dotnet build command, after at least one initial successful
full restore (via .\Restore.cmd or .\build.cmd).
This is much faster than building the whole solution.
# Build a single src project
dotnet build src\System.Windows.Forms\System.Windows.Forms.csproj
# Build a single test project
dotnet build src\test\unit\System.Windows.Forms\System.Windows.Forms.Tests.csproj
# Release configuration
dotnet build src\System.Windows.Forms\System.Windows.Forms.csproj -c Release
Tip: The repo-local SDK must be on your
PATH. Running.\start-code.cmdor.\start-vs.cmdprepends it automatically. From a plain terminal you can also run.\Restore.cmdfirst (it sets up the SDK).
.\Restore.cmd (one-time, or after SDK/package changes)..\start-vs.cmd — opens Winforms.sln with the repo-local SDK on PATH..\Restore.cmd.\start-code.cmd — opens the workspace with the repo-local SDK on PATH..\build.cmd or dotnet build <project>.| Artifact | Location |
|---|---|
| Binaries | artifacts\bin\<Project>\Debug\<tfm>\ |
| Logs | artifacts\log\ |
| Binary log | artifacts\log\Debug\Build.binlog |
| Test results | artifacts\TestResults\ |
| NuGet packages | artifacts\packages\ |
Use the MSBuild Structured Log Viewer to inspect
.binlog files when troubleshooting build errors.
artifacts\log\Debug\Build.binlog.global.json;
run .\Restore.cmd to ensure the correct SDK is available.