Skip to content
Learn Netverks

Lesson

Step 29/36 81% through track

dotnet-cli-csharp

.NET CLI for C#

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~2 min
Level
intermediate

This lesson

This lesson teaches .NET CLI for C#: the syntax, patterns, and safety habits you need before advancing in C#.

Teams still ship .NET CLI for C# in C# codebases—skipping it leaves gaps in debugging and code reviews.

You will apply .NET CLI for C# in contexts like: Internal libraries, CLI tools, and microservices versioned with NuGet.

Write C# with Console.WriteLine (top-level or Program), click Run on server—the dev runner uses dotnet build/run on a temp net8 project (requires .NET SDK; LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

The dotnet CLI creates, builds, tests, and runs .NET projects cross-platform—replacing Visual Studio-only workflows for many teams. The playground simulates a single-file console app; locally you use full SDK projects.

Essential commands

dotnet new console -n MyApp
cd MyApp
dotnet build
dotnet run
dotnet test

dotnet new list shows templates (classlib, web, xunit). dotnet --info prints installed SDKs and runtimes.

Project file basics

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
</Project>

Important interview questions and answers

  1. Q: dotnet build vs run?
    A: build compiles to IL in bin/; run builds if needed then executes with the appropriate runtime.
  2. Q: SDK-style projects?
    A: Concise MSBuild files with implicit usings and global.json for SDK pinning—standard since .NET Core 3+.

Self-check

  1. What command creates a console template?
  2. Where does build output land?

Tip: Run dotnet new list to see templates—dotnet new console, classlib, and xunit cover most local workflows.

Interview prep

dotnet new vs dotnet build?

dotnet new scaffolds a project from a template; dotnet build compiles an existing project to IL.

dotnet run does what?

Builds if needed, then launches the application—convenient for local development loops.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • dotnet new console?
  • dotnet watch?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump