Buildalyzer icon indicating copy to clipboard operation
Buildalyzer copied to clipboard

Running Build in parallel produces inconsistent results on Linux

Open zonets opened this issue 5 years ago • 2 comments

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:

  1. Works on Windows 10 with same .Net Core SDK version (no projects are ever skipped).
  2. The number of skipped projects is random: from 0 (rarely) to up to about 10 (out of about 100 projects).
  3. dotnet msbuild returns 0 for all the projects.
  4. 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 Build sequentially (by removing .AsParallel() above).

zonets avatar Apr 08 '20 01:04 zonets

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!

daveaglick avatar Jun 24 '20 01:06 daveaglick

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.

zonets avatar Aug 06 '20 19:08 zonets