Quick start
Run the tool from the root of your repository. With no arguments, it compares your working tree against the current
HEAD, counting everything staged, unstaged and untracked.
dotnet affected --verbose1 files have changed referenced by 1 projects0 NuGet Packages have changed5 projects are affected by these changes0 projects were excludedChanged ProjectsName PathDotnetAffected.Core /repo/src/DotnetAffected.Core/DotnetAffected.Core.csproj
Affected ProjectsName Pathdotnet-affected /repo/src/dotnet-affected/dotnet-affected.csprojdotnet-affected.Benchmarks /repo/benchmarks/dotnet-affected.Benchmarks/dotnet-affected.Benchmarks.csprojdotnet-affected.Tests /repo/test/dotnet-affected.Tests/dotnet-affected.Tests.csprojDotnetAffected.Core.Tests /repo/test/DotnetAffected.Core.Tests/DotnetAffected.Core.Tests.csprojDotnetAffected.Tasks /repo/src/DotnetAffected.Tasks/DotnetAffected.Tasks.csprojWRITE: /repo/affected.projReading the output
Section titled “Reading the output”Changed projects are the projects that own at least one changed file. Affected projects are the projects that depend — directly or transitively — on something that changed. The two lists are disjoint: a project appears under changed or under affected, never both.
The generated affected.proj contains both lists, because everything that changed and everything affected by those
changes needs to be built:
<Project Sdk="Microsoft.Build.Traversal/4.1.82"> <ItemGroup> <ProjectReference Include="/repo/benchmarks/dotnet-affected.Benchmarks/dotnet-affected.Benchmarks.csproj" /> <ProjectReference Include="/repo/src/dotnet-affected/dotnet-affected.csproj" /> <ProjectReference Include="/repo/src/DotnetAffected.Core/DotnetAffected.Core.csproj" /> <ProjectReference Include="/repo/src/DotnetAffected.Tasks/DotnetAffected.Tasks.csproj" /> <ProjectReference Include="/repo/test/dotnet-affected.Tests/dotnet-affected.Tests.csproj" /> <ProjectReference Include="/repo/test/DotnetAffected.Core.Tests/DotnetAffected.Core.Tests.csproj" /> </ItemGroup></Project>You can then treat it like any other project file:
dotnet test affected.projSee Build and test what changed for the full workflow.
Comparing against something else
Section titled “Comparing against something else”--from names the baseline — a branch, tag or commit — and --uncommitted chooses how much of the working tree
counts on top of it:
# Everything since the branch was cut, working tree includeddotnet affected --from origin/main
# Commits only, ignoring a dirty working tree — what CI wantsdotnet affected --from origin/main --uncommitted noneLook before you write
Section titled “Look before you write”--dry-run prints what would be written instead of creating files, and describe prints the changed and affected
projects without producing any output file at all:
dotnet affected --dry-rundotnet affected describe--assume-changes pretends a project changed, which is a quick way to explore the blast radius of a change before
making it:
dotnet affected describe --assume-changes DotnetAffected.CoreWhen nothing changed
Section titled “When nothing changed”When no project changed and nothing is affected, the tool writes no output and exits with code 166 instead of 0.
Use that to skip build and test steps entirely — see Exit codes.