How dotnet-affected works
mainThe tool determines which projects need to be rebuilt or retested by following these steps:
- Discovery: It finds all
.csproj,.fsproj, and.vbprojfiles in the repository. - Graph Building: It uses MSBuild to create a
ProjectGraphrepresenting project dependencies. - Change Detection: It runs
git diffto identify changed files and maps them to their respective projects. It also detects changes toDirectory.Packages.propsto identify NuGet package changes. - Impact Analysis: It uses the
ProjectGraphto find all projects transitively affected by the changed projects or packages.
For example, if Project A is a dependency of Project B, and Project A changes, dotnet-affected will mark both Project A and Project B as affected.