Skip to content

fix(build): make build/clean tools non-blocking to match async contract#96

Open
fivestar1103 wants to merge 1 commit into
CodingWithCalvin:mainfrom
fivestar1103:fix/build/async-non-blocking-build
Open

fix(build): make build/clean tools non-blocking to match async contract#96
fivestar1103 wants to merge 1 commit into
CodingWithCalvin:mainfrom
fivestar1103:fix/build/async-non-blocking-build

Conversation

@fivestar1103

Copy link
Copy Markdown

Problem

build_solution, build_project, and clean_solution are documented as asynchronous ("runs asynchronously; use build_status to 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_solution consistently returns The operation timed out. instead of Build started. Because the blocking call also freezes the Visual Studio UI thread for the whole build, build_status and build_cancel can't run either — so the documented "start build, then poll build_status" workflow is impossible on any large solution.

Root cause

src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs calls the EnvDTE SolutionBuild APIs with the wait flag set to true, right after SwitchToMainThreadAsync():

dte.Solution.SolutionBuild.Build(true);                       // BuildSolutionAsync
dte.Solution.SolutionBuild.BuildProject(config, path, true);  // BuildProjectAsync
dte.Solution.SolutionBuild.Clean(true);                       // CleanSolutionAsync

The final boolean is WaitForBuildToFinish / WaitForCleanToFinish; true blocks on the UI thread until the whole operation finishes.

Fix

Pass false so the build/clean is queued and the call returns immediately. This restores the documented async behavior and lets build_status observe the InProgress -> Done transition as intended.

Testing

No automated coverage — the repo has no test harness yet (#11); this is a minimal per-call flag flip.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant