📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 0 — Developer Tooling Foundation

The tools professional .NET engineers use every day: IDEs, debuggers, the .NET CLI, the SDK-style project system and MSBuild. Targets .NET 10 LTS.

  1. Walk through the dotnet restore, build, test and publish flow. What does each step produce, and why do CI pipelines use --no-restore and --no-build?

    The CLI pipeline end to end: restore producing project.assets.json, build producing bin and obj outputs, test running against those outputs, publish producing a deployable folder, and how --no-restore and --no-build keep CI fast and consistent.

    Junior Theory .NET CLI Β· πŸ”— 3 follow-ups
  2. How does dotnet test work, and how do you filter tests, collect code coverage and publish results in CI?

    Running tests from the CLI: how dotnet test discovers and runs tests, VSTest filters, loggers and TRX results, Coverlet and Microsoft code coverage, hang and crash diagnostics, parallelism, and Microsoft.Testing.Platform in .NET 10.

    Intermediate Theory .NET CLI Β· πŸ”— 2 follow-ups
  3. What are your options with dotnet publish: framework-dependent or self-contained, single-file, trimming, ReadyToRun, Native AOT and container images? How do you choose?

    Choosing a deployment shape with dotnet publish for .NET 10: runtime identifiers, framework-dependent vs self-contained, single-file, trimming, ReadyToRun, Native AOT and SDK-built container images, with their size, start-up and compatibility trade-offs.

    Mid-Level Theory .NET CLI Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  4. dotnet restore fails in CI with NU1301 or 401 Unauthorized against a private NuGet feed, but works on your machine. How do you diagnose and fix it?

    Troubleshooting restore failures: how NuGet finds sources and credentials through nuget.config, credential providers and CI service connections, package source mapping, lock files, caches, NuGet Audit, and protecting against dependency confusion.

    Mid-Level Debugging .NET CLI Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. How do you create and publish a NuGet package with dotnet pack, including versioning, package metadata, symbols and signing?

    Packaging a reusable library with dotnet pack: required and recommended metadata, SemVer versioning from CI, README and licence, symbols and Source Link, deterministic builds, package validation, signing and pushing to a feed.

    Intermediate Theory .NET CLI Β· πŸ”— 3 follow-ups
  6. What are .NET tools, and how do global tools differ from local tools with a tool manifest and dotnet tool restore?

    Covers dotnet tool: global vs local vs tool-path installs, the .config/dotnet-tools.json manifest, restore in CI, one-shot execution in .NET 10, and supply-chain safety.

    Junior Theory .NET CLI Β· πŸ”— 3 follow-ups
  7. How do you apply EF Core migrations safely in a CI/CD pipeline using dotnet ef, and why not just call Database.Migrate() at application startup?

    Covers dotnet ef migrations in CI/CD: --project/--startup-project, design-time factories, idempotent SQL scripts, migration bundles, pending model change checks, and why startup migration is risky.

    Senior RealWorldScenario .NET CLI Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. Review this CI pipeline that builds, tests and publishes a .NET 10 service with the dotnet CLI and dotnet format. What would you change and why?

    A code review of a CI pipeline: redundant restores, missing --no-restore/--no-build, Release configuration, locked restore, dotnet format --verify-no-changes, test results and coverage, and publish options.

    Mid-Level CodeReview .NET CLI Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. How does the .NET SDK decide which SDK version to use, and how does global.json change that?

    SDK resolution: how the dotnet host picks an SDK, what global.json's version, rollForward and allowPrerelease settings do, why pinning matters for IDEs and CI, and how to diagnose 'compatible SDK not found' failures.

    Mid-Level Debugging Project System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. What is an SDK-style .csproj, and how does it differ from an old-style project file?

    The modern project file: the Sdk attribute, implicit imports, default globbing of source files, PackageReference, and why SDK-style projects are short, mergeable and cross-platform.

    Beginner Theory Project System Β· πŸ”— 3 follow-ups
  11. What is the difference between a .sln and a .slnx solution file, and when would you use a solution filter?

    Solutions versus projects, the classic .sln format, the XML .slnx format that is the default for new solutions in the .NET 10 SDK, migrating with dotnet sln migrate, and .slnf solution filters for large repos.

    Junior Theory Project System Β· πŸ”— 3 follow-ups
  12. What are target framework monikers like net8.0, net9.0 and net10.0, how do you choose one, and when should you multi-target?

    TFMs and the .NET support lifecycle: what net8.0/net9.0/net10.0 and OS-specific TFMs mean, LTS versus STS, choosing targets for apps versus libraries, multi-targeting with TargetFrameworks and conditional code, and .NET 11 awareness.

    Intermediate Theory Project System Β· πŸ”— 3 follow-ups
  13. What are runtime identifiers (RIDs), and when do you need to set one in a .NET project?

    Runtime identifiers: portable RIDs like linux-x64 and win-arm64, when a RID is needed (self-contained, single-file, AOT, native assets), RuntimeIdentifier versus RuntimeIdentifiers, the .NET 8 move to portable RIDs, and RID-specific NuGet assets.

    Intermediate Theory Project System Β· πŸ”— 2 follow-ups
  14. How do Directory.Build.props and Directory.Build.targets work, and what belongs in each?

    Shared build configuration: how MSBuild finds and imports Directory.Build.props early and Directory.Build.targets late, nearest-file-wins and chaining with GetPathOfFileAbove, what to put in each, conditions per project type, and debugging with preprocess and binary logs.

    Mid-Level Theory Project System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  15. What is the difference between a PackageReference and a ProjectReference, and how do PrivateAssets and transitive dependencies affect consumers?

    Referencing code in .NET: NuGet PackageReference versus ProjectReference, version ranges and floating versions, transitive flow, PrivateAssets/IncludeAssets/ExcludeAssets, ReferenceOutputAssembly, and when to use each.

    Intermediate Theory Project System Β· πŸ”— 3 follow-ups
  16. Your solution has 80 projects with drifting NuGet versions. How would you introduce Central Package Management with Directory.Packages.props, and what are the pitfalls?

    Central Package Management in practice: Directory.Packages.props, ManagePackageVersionsCentrally, PackageVersion items, VersionOverride, GlobalPackageReference, transitive pinning, NU1008 and NU1507, migration steps and governance.

    Senior RealWorldScenario Project System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  17. You are asked to set build governance for a monorepo of 250 .NET projects owned by twelve teams. How would you design the repo-wide build configuration, and how do you keep it healthy?

    Staff-level design of repo-wide .NET build governance: global.json, layered Directory.Build files, Central Package Management, nuget.config and lock files, analyser and warning policy, artefact layout, CODEOWNERS, shared pipelines, exception processes, build performance and metrics.

    Staff / Architect Architecture Project System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  18. What is MSBuild, and how do properties, items, targets and tasks fit together when you build a .NET project?

    MSBuild fundamentals: the evaluation and execution phases, properties, items and metadata, targets and their ordering, tasks, global properties, incremental builds with Inputs and Outputs, and how dotnet build maps onto MSBuild.

    Junior Theory Build System Β· πŸ”— 3 follow-ups
  19. What is the difference between Debug and Release builds in .NET, and why can code behave differently between them?

    Build configurations: what Debug and Release change (optimisation, DEBUG/TRACE constants, debugging information, JIT behaviour), which commands default to which, custom configurations, and why behaviour can differ.

    Beginner Theory Build System Β· πŸ”— 3 follow-ups
  20. How does conditional compilation work in C#, and when should you use #if, DefineConstants or the [Conditional] attribute instead of run-time configuration?

    Conditional compilation in .NET: preprocessor directives, DefineConstants and implicit symbols (DEBUG, TFM and OS symbols), the [Conditional] attribute's call-site semantics, feature switches, and why most environment differences belong in run-time configuration.

    Intermediate Theory Build System Β· πŸ”— 3 follow-ups

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me