What is the difference between framework-dependent and self-contained publishing?

IntermediateConcept.NET builds (dotnet CLI)
Answer

Short answer

A framework-dependent publish contains only your app and its libraries; the target machine must have the .NET runtime installed. A self-contained publish bundles the runtime too, so it runs on a machine with no .NET installed — but it's much larger and tied to one OS/CPU (runtime identifier).

Commands

dotnet publish -c Release -o out                                   # framework-dependent
dotnet publish -c Release -r linux-x64 --self-contained -o out     # self-contained
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true   # one file
dotnet publish -c Release -r linux-x64 -p:PublishAot=true          # native AOT (fast startup)

Comparison

Framework-dependent Self-contained
Needs runtime installed Yes No
Size Small 70 MB+
Portable across OS Yes No — built for one RID
Run with dotnet App.dll ./App
Usual container base aspnet:8.0 runtime-deps:8.0

In containers

Framework-dependent on the mcr.microsoft.com/dotnet/aspnet image is the common choice. Self-contained/AOT on runtime-deps or chiseled images gives very small images with fast startup.

What to say in the interview

"Framework-dependent needs the shared runtime and stays small; self-contained bundles the runtime for one RID. In containers we usually publish framework-dependent onto the aspnet base image, or use AOT with runtime-deps when startup time and size matter."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: .NET apps: dotnet build & publish

More on .NET builds (dotnet CLI)