| 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 |
|
- Windows is required for WinForms runtime scenarios, test execution, and Visual Studio workflows.
- Linux is supported for command-line restore/build only; use
build.shinstead ofbuild.cmd/Restore.cmd. - Visual Studio 2022 (for IDE builds) — see
WinForms.vsconfigfor required workloads. - The repo-local .NET SDK (specified in
global.json) is used automatically bybuild.cmdandRestore.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 -restoreYou 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 -packPrefer 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 ReleaseTip: 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).
- Run
.\Restore.cmd(one-time, or after SDK/package changes). - Run
.\start-vs.cmd— opensWinforms.slnwith the repo-local SDK onPATH. - Build normally (Ctrl+Shift+B).
- (Optional)
.\Restore.cmd .\start-code.cmd— opens the workspace with the repo-local SDK onPATH.- Build from the integrated terminal:
.\build.cmdordotnet 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.
- Most errors are compile errors — fix them as usual.
- MSBuild task errors — inspect
artifacts\log\Debug\Build.binlog. - SDK version mismatch — the repo pins its SDK in
global.json; run.\Restore.cmdto ensure the correct SDK is available. - VS preview features — if using a non-Preview VS, enable Tools → Options → Environment → Preview Features → Use previews of the .NET SDK.