Buildalyzer
Buildalyzer copied to clipboard
Running Build in parallel produces inconsistent results on Linux
This may be a MsBuildPipeLogger issue.
Environment: CentOS 7, .NET Core SDK 2.2.300
Solution: 100+ projects (targeting .Net Framework; Mono reference assemblies path is passed to MSBuild).
Code snippet (buildEnvironment contains paths to dotnet executable and MSBuild.dll):
// ...
var analyzerManager = new AnalyzerManager(solutionPath);
List<ProjectAnalyzer> projects = analyzerManager.Projects.Values.ToList();
IEnumerable<AnalyzerResult> allAnalyzerResults = null;
allAnalyzerResults = projects.AsParallel()
.Select(p => p.Build(buildEnvironment).FirstOrDefault()).ToList();
var goodAnalyzerResults = allAnalyzerResults.Where(x => x != null).ToList();
if (goodAnalyzerResults.Count != projects.Count)
{
// finding missing projects here...
}
Additional notes:
- Works on Windows 10 with same .Net Core SDK version (no projects are ever skipped).
- The number of skipped projects is random: from 0 (rarely) to up to about 10 (out of about 100 projects).
- dotnet msbuild returns 0 for all the projects.
- Replacing parallel LinQ query with other ways to run build in parallel (using async tasks) produces the same result. The problem goes away when running
Buildsequentially (by removing.AsParallel()above).
Buildalyzer 3.0.1 is now rolling out to NuGet and should (hopefully) resolve this issue. When you get a chance can you please verify that this problem is resolved? Thanks!
The linux-specific problem seems to be resolved now: I no longer have to special-case Linux. Thanks for the fix! There seems to be another concurrency issue (more subtle and not Linux-specific), I'm going to open a separate bug for that.