To build a .NET project in VS Code, open the folder that contains your .csproj, .fsproj, or .sln file, confirm the .NET SDK is installed, then run dotnet build in the integrated terminal or press the build shortcut wired to the C# Dev Kit extension. The build produces assemblies and a dependency manifest in the project's bin folder. The exact steps differ slightly depending on whether you're starting from nothing or inheriting a project you already have, and those two paths are covered separately below.

VS Code is an editor first, not a .NET toolchain. It delegates the actual compilation to the .NET SDK (the dotnet command-line interface) and layers conveniences on top through the C# extension and the newer C# Dev Kit. Understanding that split prevents most of the confusion people hit: a red squiggle in the editor and a failed build are governed by different systems, and fixing one doesn't always fix the other.

A note on versions: as of the reference date for this article, .NET 10 is the current release and .NET 8 and 9 remain in support. Exact menu labels and extension behavior can shift between releases, so if a command described here doesn't match what you see, check the extension's changelog rather than assuming the workflow is broken.

Prerequisites: SDK, Extension, and a Folder That Qualifies as a Project

Before any build can succeed, three things must be in place.

The .NET SDK. You need the SDK, not just the runtime. The runtime only executes already-compiled applications; the SDK includes the compiler, MSBuild, and the dotnet new templates. Install it from Microsoft's official download page or through your package manager (apt and dnf on Linux, Homebrew on macOS, winget on Windows). Verify it from a terminal:

If that prints a version number, the SDK is on your PATH. If it errors, the installation either didn't finish or the terminal was opened before PATH refreshed—restarting VS Code usually resolves the latter.

The extension. Install the C# extension (Microsoft's, identifier ms-dotnettools.csharp) from the Extensions view. For a fuller experience—solution explorer, test explorer, project templates—install C# Dev Kit, which depends on the base C# extension. Neither is strictly required to run dotnet build in the terminal, but they provide the build task, problem matching, and IntelliSense that make VS Code feel like a .NET IDE.

A buildable folder. A .NET project is defined by its project file (.csproj for C#, .fsproj for F#, .vbproj for Visual Basic). VS Code's build tooling locates projects by scanning the workspace folder for these files. Opening a folder that contains only .cs files, with no project file anywhere in the tree, gives you editor support but nothing to build. This is the single most common reason a "build" appears to do nothing.

Two Starting Points: Creating a Project or Opening an Existing One

The workflow splits here, and it's worth deciding which situation you're in before proceeding.

If you're starting fresh, let the SDK generate the scaffolding rather than hand-writing a project file. From a terminal in an empty folder:

The dotnet new command writes a .csproj and a Program.cs (or language equivalent) that already compiles. Swap console for webapi, classlib, maui, or another template as needed; dotnet new list shows what's installed. The code . command opens the current folder in VS Code, which matters because the workspace root should be the folder containing the project, not a parent directory several levels up. A workspace rooted too high forces the tooling to scan a large tree and can make builds and IntelliSense sluggish.

If you're opening an existing project, use File → Open Folder and select the directory that holds the project or solution file. Avoid opening a single file directly; VS Code's project awareness is folder-based, and a loose file gives you syntax highlighting without a build target. If the repository has a .sln at its root, opening that root is correct—the solution groups one or more projects and dotnet build at that level builds all of them.

Once the folder is open, give the extension a moment to restore dependencies and load the project. The status bar and the Output panel's C# channel show progress. A "project not loaded" warning usually means the SDK version required by the project (pinned in global.json or the project's target framework) isn't installed.

Building From the Integrated Terminal

The terminal route is the most transparent and the one I'd suggest for a first build, because it shows the full compiler output rather than a summarized notification.

Open the terminal with Ctrl+` (backtick) or Terminal → New Terminal. The terminal starts in the workspace root. Then:

1: Restore, if needed. dotnet restore downloads NuGet packages referenced by the project. Modern SDKs run an implicit restore during build, so you can usually skip this, but running it explicitly is useful when a build fails with missing-package errors—it separates download problems from compilation problems. 2: Build. Run dotnet build. By default this targets the Debug configuration and the framework the project declares. 3: Read the summary. A successful build ends with "Build succeeded" and a count of warnings and errors, plus the elapsed time. Failures end with "Build FAILED" and list each error with a file, line, and column. 4: Locate the output. Compiled assemblies land in bin/Debug//. For a typical library or console app on .NET 10, that path looks like bin/Debug/net10.0/. Intermediate build artifacts go to obj/.

Useful variations:

dotnet build -c Release builds the optimized configuration, output under bin/Release/. dotnet build MyProject.csproj targets a specific project when the folder contains several. dotnet build --no-restore skips the implicit restore when you know packages are current—faster in repeated builds. dotnet build -warnaserror promotes warnings to errors, handy before committing.

The terminal approach works identically on Windows, macOS, and Linux, which is why it's the reliable fallback when editor integration misbehaves.

Building Through the Editor: Tasks and the Build Shortcut

With C# Dev Kit installed, VS Code exposes build commands that wrap the same dotnet build invocation.

The default build keybinding is Ctrl+Shift+B (Cmd+Shift+B on macOS), which runs the "build" task for the active project. The first time you press it, VS Code may ask you to select a task if more than one is available. The output appears in the Terminal panel under a task-specific tab, and errors are parsed into the Problems panel, where double-clicking an entry jumps to the offending line.

You can also build from the Command Palette (Ctrl+Shift+P) by searching for ".NET: Build" or the solution explorer's context menu when Dev Kit is active. Right-clicking a project node in the Solution Explorer offers Build, Rebuild, and Clean.

A subtlety: the editor's build command targets the project the editor considers active, which is usually the one you last touched or the one the extension loaded first. In a solution with several projects, pressing the shortcut may not build what you expect. The terminal's dotnet build at the solution root builds everything, which is why it's the safer choice in multi-project repositories.

If you prefer a custom task—say, building with a specific configuration or running a pre-build script—VS Code reads .vscode/tasks.json. A minimal task that builds in Release looks like this:

The $msCompile problem matcher is what turns compiler output into clickable Problems entries. Without it, errors appear only as terminal text.

Confirming the Build Actually Worked

"Build succeeded" in the terminal is the primary signal, but a few checks confirm the result is real and usable.

First, inspect the output directory: ls bin/Debug/net10.0/ (or dir on Windows) should show your assembly—HelloBuild.dll for the console example—alongside a .deps.json dependency manifest and, for executable projects, an apphost executable. If the folder is empty despite a success message, you likely built a different project than you assumed.

Second, run it. For an executable project, dotnet run builds and launches in one step; if it prints expected output, the build is functional, not just syntactically valid.

Third, check the warning count. A build with warnings still succeeds, but warnings often flag real problems—nullable mismatches, obsolete API use, unreachable code. Treating a warning-free build as the baseline before committing saves debugging later.

Fourth, for solution-level builds, confirm every project was included. The summary line reports how many projects built; if a solution contains four projects and the summary says one, the others were skipped, usually because they target a framework the installed SDK can't build or are excluded by configuration.

When the Build Fails: Symptoms, Causes, and Reversible Fixes

Build failures fall into a few recognizable families. Start with the cheapest, most reversible checks.

"The current .NET SDK does not support targeting .NET X." The project's target framework is newer than your installed SDK, or a global.json pins an SDK version you don't have. Check dotnet --list-sdks and compare against the in the project file. Fix by installing the matching SDK or, if appropriate for your situation, adjusting the target framework. Don't lower a target framework casually—it changes which APIs are available.

NuGet restore errors ("Unable to find package," "NU1101"). The package source is unreachable, the package name or version is wrong, or the local cache is stale. Run dotnet restore on its own to see the full error, verify the package ID and version in the project file, and try dotnet nuget list source to confirm feeds are configured. Clearing the cache with dotnet nuget locals all --clear and restoring again resolves some corrupted-cache cases.

Editor shows errors but the terminal build succeeds. The two systems have diverged. Common causes: the extension is using a different SDK than the terminal (check the "C#: Select Project" or the SDK picker in the status bar), or the project loaded before a restore finished. The fix is usually to run "Developer: Reload Window" from the Command Palette or restart the C# extension via ".NET: Restart Language Server."

Terminal build fails but the editor is clean. The reverse divergence—often a stale editor cache showing old errors, or the terminal building a different project. Confirm the working directory, then rebuild in the editor.

Errors about missing files that clearly exist. Usually path or case-sensitivity issues, or files excluded by the project's glob rules. Check the .csproj for entries and confirm the file isn't in bin/ or obj/, which are excluded by default.

"MSB1003: Specify a project or solution file." You ran dotnet build in a directory with no project or solution file. cd into the right folder or pass the path explicitly.

A practical ordering: reproduce the failure in the terminal first, because its output is complete and unaffected by editor caching. Once the terminal build passes, any remaining editor errors are a tooling problem, not a code problem. If a build failure persists after restore, SDK verification, and a clean rebuild (dotnet clean then dotnet build), and the errors point into generated files or the toolchain itself rather than your source, that's the point to stop improvising and consult your team's build engineer or Microsoft's official .NET documentation for your specific SDK version.

Multi-Project Solutions, Configurations, and What the Editor Adds

Real codebases rarely consist of one project. A solution might contain a web API, a class library, and a test project, each with its own .csproj. Building at the solution level (dotnet build MySolution.sln) respects the dependency graph—libraries build before the projects that reference them—and produces output for each project under its own bin folder. Building an individual project still builds its dependencies, but only those, so the solution-level command is what you want for a full verification.

Configurations matter for output location and optimization. Debug builds include symbols and skip heavy optimization; Release builds optimize and are what you'd ship. The configuration is chosen at build time (-c Release), and the output path embeds it (bin/Release/net10.0/). Building Release locally before deployment catches optimization-sensitive bugs and trimming issues that Debug builds hide.

The editor adds conveniences on top of these commands: inline error squiggles, go-to-definition across projects, and a Solution Explorer that shows the project structure. It does not change what the compiler does. When behavior differs between the editor and the terminal, the terminal is the ground truth for whether the code compiles; the editor is the ground truth for developer experience.

A reasonable daily workflow for most teams: rely on the editor's build shortcut for fast feedback while writing code, run dotnet build at the solution root before committing, and run dotnet build -c Release in CI so the shipping configuration gets exercised on every change. That layering catches the failures each tool is best at catching.

FAQ

Does VS Code need the full Visual Studio installed to build .NET projects?

No. VS Code plus the .NET SDK plus the C# extension is sufficient. Visual Studio is a separate IDE with its own toolchain; nothing in the VS Code workflow depends on it.

Why does dotnet build succeed but dotnet run fail?

They do different things. Build compiles; run compiles and then launches, which can fail on runtime issues—a missing runtime version, a configuration or connection string the app expects, or an entry point that throws immediately. Read the run-time exception, not the build output.

Can I build without the terminal, entirely through the UI?

With C# Dev Kit, yes—the Solution Explorer's Build command and the build shortcut cover most cases. The terminal remains useful because its output is complete and it works regardless of extension state, so keeping it as a fallback is worth the small effort.

What's the difference between Clean and Rebuild?

Clean deletes build outputs; Rebuild runs Clean then Build. Reach for either when you suspect stale artifacts—after switching branches, changing SDK versions, or seeing errors in files you didn't edit. For routine changes, a plain Build is faster and sufficient.