Skip to content
Learn Netverks

Lesson

Step 31/36 86% through track

nuget-packages

NuGet packages

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches NuGet packages: the syntax, patterns, and safety habits you need before advancing in C#.

Teams still ship NuGet packages in C# codebases—skipping it leaves gaps in debugging and code reviews.

You will apply NuGet packages 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).

Toward the end of the track—consolidate before capstone-style review lessons.

NuGet is the .NET package manager—libraries ship as versioned packages referenced in .csproj, similar to Maven Central for Java. Restore downloads dependencies into a local cache.

Adding packages

dotnet add package Newtonsoft.Json
dotnet restore

Pin versions in CI; audit transitive dependencies for security advisories.

PackageReference

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Important interview questions and answers

  1. Q: dotnet restore?
    A: Downloads NuGet packages declared in project files before build.
  2. Q: Transitive dependencies?
    A: NuGet pulls dependent packages automatically—review lock files in teams.

Self-check

  1. What command adds a package to a project?
  2. Where do PackageReference entries live?

Pitfall: Pin package versions in CI—dotnet add package without version constraints can pull breaking updates on restore.

Interview prep

What is NuGet?

The .NET package manager—restore downloads dependencies listed in the csproj to a local cache before build.

PackageReference vs packages.config?

Modern SDK projects use PackageReference in the csproj; legacy projects used separate packages.config files.

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

  • PackageReference?
  • Transitive deps?

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