[Feature Request]: MSBuild Server Identifier
Summary
Server reuse across clones, can lead to issues when Shutdown, leading to errors.
Background and Motivation
When having multiple Clones of the same repository using MSBuild Server for speeding up compilation, we end up in situations where the MSBuild Server gets shutdown from the other clone, while a compilation is ongoing, resulting in errors because of Server Shutdown.
Our setup:
- Each clone have its own copy of MSBuild copied into it, and execute MSBuild Server.
Proposed Feature
Add an Identifier to the started server + nodes started by the server, so repositories can't interfere with each other. It would be optimal if:
- The Identifier could be passed as an argument or a new env var
SharedId - The Identifier would be additive to the current
CommunicationsUtilities.GetHandshakeOptionsso it would work as today if no extra identifier was added. - Add the public api to
MSBuildClientto support MSBuild Server Identifier. - Possible to use the same
SharedIdto pass to Roslyn's similar conceptSharedCompilationId
This would make it easier to control multiple msbuild servers that can't interfere with eachother.
Alternative Designs
The MSBuild Server is identified with the location, so if we have two copies of MSBuild, each would have a unique identity and MSBuild Server + Nodes.
Seems related to https://github.com/dotnet/sdk/issues/9303 and https://github.com/dotnet/sdk/issues/20183. Could this use the same SharedCompilationId property as Roslyn?
Seems related to dotnet/sdk#9303 and dotnet/sdk#20183. Could this use the same
SharedCompilationIdproperty as Roslyn?
It would make alot of sense that all MSBuild nodes and Roslyn would use the same Identifier, passing along the MSBuild SharedId to Roslyn.
@KalleOlaviNiemitalo updated the proposal to use the same Shared-Id between Roslyn and MSBuild
@hknielsen sorry, I can't repro your issue as the following steps. Did you repro you issue in your specified repo? or is there anything that I missed?
- Enable MSBuild Server with DOTNET_CLI_USE_MSBUILD_SERVER = 1
- Clone two copies of msbuild repos and execute dotnet build MSBuild.sln
- dotnet build-server shutdown when one build is done and the other is still going.
@JaynieBai We were seeing it randomly in CI. Basically it was related to rebuilds on multiple clones using the same msbuild server, where one finished and shutsdown the server.
@hknielsen and to be clear: you are explicitly setting DOTNET_CLI_USE_MSBUILD_SERVER in your CI jobs?
@rainersigwald - yeah, we are setting the env var to enable the MSBuild Servier. And calling shutdown when done. We were also not only using this on CI, so when we are done building, we cleanup resources, including shutdown the MSBuild Server
Roslyn/Razor are also hitting similar issues with the Razor compiler server and the build-server shutdown command. cc @jaredpar - it would be cool if we could find a reusable solution for our different servers.
I agree that we need to find a reusable solution for our different servers. Right now we're all solving the same problem but in different ways which each have their own flaws.