Speed up builds with solution-level compile and output reuse - #1
Draft
Antaris wants to merge 1 commit into
Draft
Conversation
Compile the resolved solution once with parallel MSBuild so shared libraries are not rebuilt for every app and test. Keep the existing extension model: BeforeBuild hooks still run first, AfterBuild hooks run after outputs exist, and projects outside the solution are built individually without project-reference rebuilds. Reuse those outputs for test, pack, and publish via --no-build, and resolve ITaskHook implementations from DI so extension hooks fire. Co-authored-by: Matthew Abbott <matt@ingeniumsoftware.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds were sequential and per-project. Each
dotnet buildon an app or test walkedProjectReferences, so a shared library was compiled again for every consumer. App publish had the same problem because it never passed--no-build.This change keeps the Cake task, hook, and extension architecture, and makes the compile step a single parallel solution build.
dotnet buildon the resolved consumer.slnwith/mso independent projects compile concurrently and each project is built once.BeforeBuild/BeforeBuildAsynccallbacks run first (code generation still happens before compile), then the solution builds, then leftover projects not in the solution are built with--no-dependencies, thenAfterBuildhooks run.--no-build/--no-restoreafter a successful compile. SDK tests in the solution usedotnet test <sln> --no-build.BuildServices.GetHooks<T>()now returnsITaskHookimplementations discovered from extension assemblies, instead of always yielding nothing.mainis unchanged. This stays oncursor/faster-solution-builds-4458.How it works
Extensions that generate sources in
BeforeBuildstill run before compile. Extensions that consume outputs inAfterBuildstill run after compile. App publish should callBuildProject(..., publish: true)after Build soHasBuiltis true and publish does not rebuild references.Test plan
dotnet build Build.sln -c Releasesucceeds--target Buildand confirm a single solution compile (libs not rebuilt per app)build-extensionsIBuildHook/IAsyncBuildHookimplementations still run (BeforeBuild before compile, AfterBuild after)--target Testand--target Packafter Build and confirm--no-buildis used.slnstill builds those leftovers individually