.NET CLI, SDK & Project Structure (csproj)
15 questions found
What is the difference between framework-dependent deployment (FDD) and self-contained deployment (SCD)?
Intermediate
Framework-dependent deployment produces a smaller output that relies on the target machine having the matching .NET runtime already installed. Self-contained deployment bundles the entire .NET runtime alongside the application, producing a larger output that can run on a machine with no .NET installed at all, at the cost of increased size and needing separate builds per target OS/architecture.
# Framework-dependent (smaller, needs runtime installed)
dotnet publish -c Release
# Self-contained (larger, standalone)
dotnet publish -c Release -r win-x64 --self-contained true
Real-world example
A SaaS company distributing a desktop agent to customer machines uses self-contained deployment so customers don't need to separately install any .NET runtime, simplifying the installation experience.
Common follow-ups: What does the -r (runtime identifier) flag control?;How does self-contained deployment interact with trimming to reduce size?
CI/CD
Publishing & Deployment;Docker & Containerization
What is Native AOT (Ahead-of-Time) compilation, and what are its benefits and constraints?
Advanced
Native AOT compiles a .NET application directly to native machine code at publish time, producing a fully self-contained native executable with no JIT compilation or full .NET runtime required at startup -- resulting in dramatically faster startup time and lower memory footprint, ideal for CLI tools, containers, and serverless functions. Constraints include no runtime reflection-based dynamic code generation, limited support for some libraries, and platform-specific builds required per target.
dotnet publish -c Release -r linux-x64 -p:PublishAot=true
# Produces a native executable with no separate .NET runtime dependency,
# starting in milliseconds instead of the usual JIT warm-up time
Real-world example
A serverless function deployed to AWS Lambda uses Native AOT to cut cold-start latency from several hundred milliseconds down to under 50ms, directly improving cost and user-perceived performance.
Common follow-ups: Why doesn't Native AOT support full reflection-based serialization?;How does trimming warning analysis help catch AOT-incompatible code?
CI/CD
Publishing & Deployment;Diagnostics & Performance
How do you add, remove, and list NuGet package references using the dotnet CLI?
Intermediate
`dotnet add package <PackageId>` adds a PackageReference to the .csproj (optionally with --version), `dotnet remove package <PackageId>` removes it, and `dotnet list package` shows all references, including outdated or vulnerable packages with the --outdated or --vulnerable flags.
dotnet add package Serilog.AspNetCore --version 8.0.0
dotnet list package --outdated
dotnet remove package Newtonsoft.Json
Real-world example
A security audit runs `dotnet list package --vulnerable` across every project in a solution as part of a scheduled CI job to catch known CVEs in third-party dependencies before they reach production.
Common follow-ups: How does --outdated differ from --vulnerable in its data source?;How do you restore packages from a private NuGet feed?
Assemblies & NuGet;.NET CLI
SDK & Project Structure (csproj)
What does the `dotnet watch` command do, and how does it speed up local development?
Beginner
`dotnet watch run` monitors source files for changes and automatically rebuilds and restarts (or hot-reloads, when possible) the application, eliminating the manual stop-edit-rebuild-restart cycle during active development. It supports Hot Reload for many code changes without a full restart, preserving application state where feasible.
dotnet watch run
# Edit a .cs file and save --
# the app automatically rebuilds and either hot-reloads or restarts
Real-world example
A developer building an ASP.NET Core API uses `dotnet watch run` throughout the day, seeing most controller and service changes reflected within a couple of seconds without manually restarting the server.
Common follow-ups: What kinds of code changes support Hot Reload versus requiring a full restart?;How does dotnet watch differ from IDE-integrated hot reload?
.NET CLI
SDK & Project Structure (csproj);Diagnostics & Performance
How do project references (<ProjectReference>) differ from package references, and how do they affect build order?
Advanced
A <ProjectReference> points to another project's .csproj file within the same solution/repository, letting MSBuild automatically determine build order (dependencies built first) and always use the latest local source rather than a published NuGet package. This is preferred during active co-development of related projects, while PackageReference is used for external or independently versioned/released dependencies.
<ItemGroup>
<ProjectReference Include="..\MyLib\MyLib.csproj" />
</ItemGroup>
<!-- MSBuild automatically builds MyLib first, then this project -->
Real-world example
A solution with an API project and a shared Models class library uses a ProjectReference so any change to Models is immediately reflected in the API build without needing to publish and consume an internal NuGet package.
Common follow-ups: When should an internal library be published as a NuGet package instead of referenced directly?;How does circular project reference detection work?
Assemblies & NuGet;.NET CLI
SDK & Project Structure (csproj)