hoffi / gulp-msbuild

gulp-msbuild has moved to https://github.com/fluffynuts/gulp-msbuild.
MIT License
53 stars 44 forks source link

msbuild fails on multi-cpu machine when maxcpucount = 0 or > 1 #54

Open jflsitecore opened 7 years ago

jflsitecore commented 7 years ago

Trying to build Sitecore Habitat project (not that it matters, but just for reference)

When I try to run the msbuild gulp task it eventually fails. Gulp is being called by TeamCity via PowerShell runner. It's a simple "gulp".

It builds fine from CLI or Windows PowerShell (interactive) but fails when run in TeamCity.

I had found this issue before so I created a new gulpfile with maxcpucount = 1 and the build works fine then. As soon as the computer has multiple CPUs and maxcpucount =0 then it fails.

gulp task: ` gulp.task("Build-Solution", function () { var targets = ["Build"]; if (config.runCleanBuilds) { targets = ["Clean", "Build"]; } var solution = "./" + config.solutionName + ".sln"; return gulp.src(solution)

  .pipe(msbuild({
      targets: targets,
      configuration: config.buildConfiguration,
      logCommand: false,
      verbosity: "minimal",
      stdout: true,
      errorOnFail: true,
      maxcpucount: 0,
      nodeReuse: false,
      toolsVersion: 14.0,
      properties: {
        Platform: config.buildPlatform
      }
    }));

});`

error:

[07:02:27][Step 11/19] Sitecore.Feature.News.Tests -> E:\BuildAgent\work\de74fbbbff5d6869\p\h\src\feature\News\tests\bin\Debug\Sitecore.Feature.News.Tests.dll [07:02:28][Step 11/19] [07:02:28] MSBuild failed with code 1! [07:02:28][Step 11/19] [07:02:28] 'Build-Solution' errored after 1.08 min [07:02:28][Step 11/19] [07:02:28] Error: MSBuild failed with code 1! [07:02:28][Step 11/19] at ChildProcess.<anonymous> (E:\BuildAgent\work\de74fbbbff5d6869\p\h\node_modules\gulp-msbuild\lib\msbuild-runner.js:53:25) [07:02:28][Step 11/19] at emitTwo (events.js:106:13) [07:02:28][Step 11/19] at ChildProcess.emit (events.js:191:7) [07:02:28][Step 11/19] at maybeClose (internal/child_process.js:886:16) [07:02:28][Step 11/19] at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) [07:02:28][Step 11/19] [07:02:28] 'default' errored after 1.18 min [07:02:28][Step 11/19] [07:02:28] Error in plugin 'run-sequence(Build-Solution)' [07:02:28][Step 11/19] Message: [07:02:28][Step 11/19] MSBuild failed with code 1! [07:02:28][Step 11/19] Stack: [07:02:28][Step 11/19] Error: MSBuild failed with code 1! [07:02:28][Step 11/19] at ChildProcess.<anonymous> (E:\BuildAgent\work\de74fbbbff5d6869\p\h\node_modules\gulp-msbuild\lib\msbuild-runner.js:53:25) [07:02:28][Step 11/19] at emitTwo (events.js:106:13) [07:02:28][Step 11/19] at ChildProcess.emit (events.js:191:7) [07:02:28][Step 11/19] at maybeClose (internal/child_process.js:886:16) [07:02:28][Step 11/19] at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) [07:02:28][Step 11/19] [07:02:28] '03-Publish-All-Projects' errored after 1.08 min [07:02:28][Step 11/19] [07:02:28] Error in plugin 'run-sequence(default)' [07:02:28][Step 11/19] Message: [07:02:28][Step 11/19] MSBuild failed with code 1! [07:02:28][Step 11/19] Stack: [07:02:28][Step 11/19] Error: MSBuild failed with code 1! [07:02:28][Step 11/19] at ChildProcess.<anonymous> (E:\BuildAgent\work\de74fbbbff5d6869\p\h\node_modules\gulp-msbuild\lib\msbuild-runner.js:53:25) [07:02:28][Step 11/19] at emitTwo (events.js:106:13) [07:02:28][Step 11/19] at ChildProcess.emit (events.js:191:7) [07:02:28][Step 11/19] at maybeClose (internal/child_process.js:886:16) [07:02:28][Step 11/19] at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) [07:02:28][Step 11/19] [07:02:28] '03-Publish-All-Projects' errored after 1.08 min [07:02:28][Step 11/19] [07:02:28] Error in plugin 'run-sequence(Build-Solution)' [07:02:28][Step 11/19] Message: [07:02:28][Step 11/19] MSBuild failed with code 1! [07:02:28][Step 11/19] Stack: [07:02:28][Step 11/19] Error: MSBuild failed with code 1! [07:02:28][Step 11/19] at ChildProcess.<anonymous> (E:\BuildAgent\work\de74fbbbff5d6869\p\h\node_modules\gulp-msbuild\lib\msbuild-runner.js:53:25) [07:02:28][Step 11/19] at emitTwo (events.js:106:13) [07:02:28][Step 11/19] at ChildProcess.emit (events.js:191:7) [07:02:28][Step 11/19] at maybeClose (internal/child_process.js:886:16) [07:02:28][Step 11/19] at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) [07:02:28][Step 11/19] Process exited with code 0

hoffi commented 7 years ago

Hm I cannot see any error in gulp-msbuild as MSBuild returned the error. Looks like a problem with the machine or the project.

You could set logCommand: true and start the command yourself or turn on diagnostic logging into a file.

hrishikeshtt commented 6 years ago

I am facing the same issue and errors which I got are like The process cannot access the file 'E:\TFS\Gemini 2.0\Dev\Main\Libraries\Foundation\Dictionary\Asl.Foundation.Dictionary\obj\Debug\Asl.Foundation.Dictionary.dll' because it is being used by another process.' [E:\TFS\Gemini 2.0\Dev\Main\Libraries\Foundation\Dictionary\Asl.Foundation.Dictionary\Asl.Foundation.Dictionary.csproj]

Copying file obj\Debug\Package\PackageTmp\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll to E:/Webs/Sitecore9/8\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll failed. The process cannot access the file 'E:/Webs/Sitecore9/8\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll' because it is being used by another process. [E:\TFS\Gemini 2.0\Dev\Main\MultiTenant Features\Asl.Feature.Search\Asl.Feature.Search\Asl.Feature.Search.csproj]