fix(build): make build/clean tools non-blocking to match async contract#96
Open
fivestar1103 wants to merge 1 commit into
Open
Conversation
BuildSolution, BuildProject and CleanSolution called the EnvDTE SolutionBuild APIs with WaitForBuildToFinish/WaitForCleanToFinish set to true, on the UI thread.
This blocks the Visual Studio main thread until the entire build/clean completes, which contradicts the tool description ("runs asynchronously; use build_status to check progress; returns immediately after starting the build").
Two consequences:
- For large solutions the RPC call never returns in time and the MCP client reports "The operation timed out.",
instead of "Build started".
- While the UI thread is blocked, build_status/build_cancel cannot run,
so the documented polling workflow is impossible.
Pass false so the build/clean is queued and the call returns immediately,
letting build_status observe the InProgress -> Done transition as intended.
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.
Problem
build_solution,build_project, andclean_solutionare documented as asynchronous ("runs asynchronously; usebuild_statusto check progress; returns immediately after starting the build"), but they block until the build/clean fully completes.This shows up in daily real-world use: I drive builds through this MCP on a large Unreal Engine 5 (C++) solution, and
build_solutionconsistently returnsThe operation timed out.instead ofBuild started. Because the blocking call also freezes the Visual Studio UI thread for the whole build,build_statusandbuild_cancelcan't run either — so the documented "start build, then pollbuild_status" workflow is impossible on any large solution.Root cause
src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cscalls the EnvDTESolutionBuildAPIs with the wait flag set totrue, right afterSwitchToMainThreadAsync():The final boolean is
WaitForBuildToFinish/WaitForCleanToFinish;trueblocks on the UI thread until the whole operation finishes.Fix
Pass
falseso the build/clean is queued and the call returns immediately. This restores the documented async behavior and letsbuild_statusobserve theInProgress -> Donetransition as intended.Testing
No automated coverage — the repo has no test harness yet (#11); this is a minimal per-call flag flip.