hoffi/gulp-msbuild

MSBuild task fails when running remotely via ssh

Closed this issue · 4 comments

Hi. I have the following gulp msbuild task:

gulp.task('build', function () {
  return gulp.src('./dotnet/core/build.sln')
    .pipe(msbuild({
      toolsVersion: 12.0,
      //targets: ['Clean', 'Build'],
      targets: ['Build'],
      configuration: 'Debug',
      errorOnFail: true,
      stderr: true,
      stdout: false,
      logCommand: true,
      verbosity: 'diagnostic',
      nologo: true
    }))
    .on('error', function (err) {
      throw new Error(err);
    });
});

When I run this task remotely via ssh, I keep getting this error (see below). The task runs fine when I run it on the server directly via RDP, though. Any idea what can be causing this error and how to fix it? Thank you very much.

$ gulp build
[11:29:47] Starting 'build'...
[11:29:47] Using MSBuild command: C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\MSBuild.exe C:\Users\dmoore\projects\amgen-sites\webcms2-core-mirror-colddata\dotnet\core\build.sln /target:Build /verbosity:diagnostic /toolsversion:12.0 /nologo /maxcpucount /property:Configuration=Debug
[11:29:52] MSBuild failed with code 1!
[11:29:52] 'build' errored after 4.91 s
[11:29:52] Error: Error: MSBuild failed with code 1!
    at DestroyableTransform.<anonymous> (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\gulpfile.js:81:13)
    at DestroyableTransform.emit (events.js:129:20)
    at onwriteError (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:322:10)
    at onwrite (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:339:11)
    at WritableState.onwrite (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:123:5)
    at afterTransform (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:81:3)
    at TransformState.afterTransform (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:58:12)
    at C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\index.js:23:23
    at ChildProcess.<anonymous> (C:\Users\app\projects\amgen-sites\webcms2-core-mirror-colddata\node_modules\gulp-msbuild\lib\msbuild-runner.js:53:16)
    at ChildProcess.emit (events.js:110:17)

I've also found a MSBuild***.failure.txt file in my home directory with this:

UNHANDLED EXCEPTIONS FROM PROCESS 4896:
=====================
3/29/2016 7:45:06 AM
System.IO.IOException: Pipe is broken.
   at System.IO.Pipes.NamedPipeServerStream.CheckConnectOperationsServer()
   at System.IO.Pipes.NamedPipeServerStream.BeginWaitForConnection(AsyncCallback callback, Object state)
   at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.PacketPumpProc()
===================
hoffi commented

Hi,

i think this is a problem with your ssh connection. Looks like your connection is closed while building for whatever reasons.
Maybe it helps when you enable Keep-Alive in your SSH-Config? Like:

Host *
  TCPKeepAlive yes

Thank you for the quick reply. Tried your suggestion just in case, but still the same error. Also, don't think it applies, since I am actually ssh'ing to a Windows 2008 R2 server first (runs OpenSSH server) and only then run the build task, e.g.:

$ ssh some.host.com
$ /path/to/npm/gulp build

The SSH connection stays on all this time. Just get that error when running the gulp task itself. No disconnects or any other suspicious messages. Seems to happen when medium to large projects that have some output. Smaller projects build OK this way. Too much going through the pipe that someone can't keep up with?

hoffi commented

Hm does it help when you disable stderr output: stderr: false?

However im still unsure that this is a problem with gulp. You could try to run MSBuild manually on the server by executing the logged msbuild command:

C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\MSBuild.exe C:\Users\dmoore\projects\amgen-sites\webcms2-core-mirror-colddata\dotnet\core\build.sln /target:Build /verbosity:diagnostic /toolsversion:12.0 /nologo /maxcpucount /property:Configuration=Debug

If it still fails with the same error i would say msbuild does not play nicely with ssh.

I agree. The shell given by openssh from MLS Software is some sort of stripped down crappy light version of cygwin. I've switched to the latest cygwin package instead and everything works fine now. Thank you for your help!