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.
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.