BuildAbortedException is thrown when MaxNodeCount > 1
When using the Microsoft.Build API version "15.1.0-preview-000545-01" with BuildParameters.MaxNodeCount > 1, I get this exception:
Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled.Failed to successfully launch or connect to a child MSBuild.exe process.Verify that the MSBuild.exe "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.
at Microsoft.Build.Execution.BuildManager.EndBuild()
This small program reproduces the issue:
https://github.com/debanne/dotnet-builder/blob/issue_BuildAbortedException/Builder/Program.cs#L89
The 3 projects A, A.UTest and B are correctly built when MaxNodeCount equals 1 or if I build only 2 projects. But if I build 3 of them, then the exception is thrown. I also noticed that the problem disappears if the ProjectReference to A.csproj in A.UTest.csproj is removed.
What environment are you running the application from? (a VS command prompt, a command prompt with no VS environment set, the VS debugger itself?)
Sorry, I had to push a new commit on https://github.com/debanne/dotnet-builder as I forgot to include some test resources. I get the error when launching the program with the 3 environments you mentioned. I attach the full output. Builder_output.txt
I updated the failing example (https://github.com/debanne/dotnet-builder/tree/issue_BuildAbortedException) to version 15.1.548 of the Microsoft.Build nugets.
I sent a PR to fix the issue and explain: https://github.com/debanne/dotnet-builder/pull/1
The basic issue is you're compiling against our NuGet package (good), but running MSBuild from the code in the NuGet package (not as good). Before this was easy because MSBuild was in the GAC. So you could think you're running your own copy of MSBuild assemblies, but you're really not since it's in the GAC. The fix is to behave more like before and run from the copy of MSBuild has the features installed you need. This is unfortunately somewhat difficult now that you can have multiple copies of Visual Studio installed (say Community with C# and Enterprise with C++ installed). To really do this right you have to pick the right copy of VS depending on what you're building. The PR I sent is best effort and picks the one from the dev console (there's 1 per instance of VS so that's likely the right choice) or setup API. Setup API is needed if you want to double click the exe or run from a standard command prompt.
Make sense? I'm going to close the issue. Feel free to reopen or open another if there's another issue. Hope that helps!