Code Monkey home page Code Monkey logo

gulp-msbuild's Introduction

gulp-msbuild's People

Contributors

bdukes avatar ckotzbauer avatar fluffynuts avatar gmahomarf avatar hoffi avatar marshall007 avatar mhh avatar niksko avatar perosb avatar ravenox avatar richard-edwards avatar ryanmolden avatar seniorquico avatar siliconrob avatar sirlancelot avatar sjhowie avatar tsubik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-msbuild's Issues

publish

Is there a way to publish using publish profile?

MSBuild task fails when running remotely via ssh

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()
===================

"end" event no longer emitted

Hi,
using v0.3.3 the end event is properly emitted after msbuild ended.
In the latest version the end event seems no longer working, also if the needed flag (emitEndEvent) in the options is set to true.

gulp.task('vsbuild:pilot', () => {
gulp.src("./package/" + projectSettings.addinName + "Pilot/.csproj")
.pipe(msbuild({
targets: ['Package'],
toolsVersion: 14.0,
emitEndEvent: true,
properties: {
OutputPath: '../../' + projectSettings.distFoldername + '/pilot/'
},
fileLoggerParameters: 'LogFile=./build-pilot.log;Append;Verbosity=normal'
}))
.on('end', function() {
console.log(".on('end', function() {"); // end is called with 0.3.3 of gulp-msbuild, but not with the latest version
gulp.src(projectSettings.distFoldername + "/pilot/app.publish/" + pkg.version + '.0/
.app')
.pipe(gulp.dest(projectSettings.distFoldername + '/latest'));
});
});

Task finished before build is complete?

Hi,

When I run a job with gulp-msbuild, the task is finished before the build is complete:

[14:41:19] Starting 'build'...
[14:41:19] Finished 'build' after 6.97 ms
[14:41:31] Build complete!

I'd like to run a task after the build is finished, how can I do this?

Enhancement: add some config validation and help messages

Hi

It would be great if this tool warned you if you were incorrectly using invalid config values. I just spent multiple days trying to get a web publish to work, only to realise that the syntax for targets is targets and not target, and that you should be passing an array instead of just a single value.

Instead of silently choosing defaults, perhaps there should be some validation and suggestions of the value you might have been looking for?

gulp-msbuild does not appear to be calling MSBUILD (possible setup issue on my part?)

Hello,

I inherited a project which uses gulp-msbuild, and I can't seem to get it to work. The gulp task runs, but it doesn't seem to be actually calling MSBUILD. I suspect it is a path problem or something. My gulpfile is in a subdirectory one level down from my Visual Studio solution file, which contains my MSBUILD tasks. The gulp task looks like this:

gulp.task('msbuild', function (cb) {
log('Building Visual Studio solution');
return gulp.src(pkg.paths.solution)
.pipe(plug.msbuild({
targets: ['Clean', 'Build'],
toolsVersion: 12.0 // Default: 4.0
}, cb));

});

The pkg.paths.solution variable points to a property of a JS object in the package.json file; that value looks like this:

"./TheSolutionName.sln",

The "plug.msbuild" aspect of it uses

var plug = require('gulp-load-plugins')();

That should not be the issue, because we have many other gulp tasks which use "gulp-load-plugins", and they're working fine.

I can run MSBUILD directly, from the DOS command line (it's a Windows 7 machine), when I'm at the same directory where the .sln file resides; that works. But when I try to do it from the gulp task, gulp-msbuild doesn't actually seem to be calling it.

Because I couldn't find a lot of documentation by googling (trying to find debugging or troubleshooting advice), that suggests most people must be using it without any problems.

Still, I just wanted to verify,

  • it actually works, is that correct? People are out there in the field, using it?
  • do you see anything wrong with the format of my path variable that points to the solution?
  • it should behave just like MSBUILD that runs at the command line? From reading the source code, it just appears to be a wrapper around the MSBUILD command line. For example, if I specify a verbosity level which should send the MSBUILD output text to the console, then when I call it from gulp-msbuild, it should output that text in the same way that MSBUILD itself would do, if I called it from the command line?
  • can you suggest any debugging tricks so I can try and see why it does not appear to be calling my MSBUILD tasks? (What I'm trying to do is very simple; I just want to do a "Clean" and "Rebuild", and maybe also do another task I have which does a one-off transformation of a web.config file.)

Any help appreciated

Thank you,

Dave

Fails to locate correct MSBuild when building database project using SSDT for VS 2017

My team is migrating to gulp and we are trying to build database project on our build agent using SSDT tools for visual studio 2017. The agent is clean (no vs), only build tools and SSDT tools are installed:

Using the following gulp task:

var gulp = require('gulp');
var msbuild = require("gulp-msbuild");

gulp.task("DW-database-build", function () {
	return gulp.src("../Database/Database.sqlproj")
		.pipe(
			msbuild({
				targets: ['Clean', 'Build'],
				toolsVersion: 15.0,
				maxcpucount: 4,
				verbosity: "quiet",
				nodeReuse: false,
				properties: {
					Configuration: 'Release',
					VisualStudioVersion: '15.0',
					Platform: 'AnyCPU'
				}
			})
		);
});

gulp uses msbuild located in BuilTools folder which fails to locate SSDT

Build started 25.9.2017 14:09:40.
     0>Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\$(MSBuildToolsVersion)\Microsoft.Common.props using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild
       Property reassignment: $(MSBuildProjectExtensionsPath)="C:\TeamCity\buildAgent\work\DWX_CI\Database\obj\" (previous value: "obj\") at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Microsoft.Common.props (58,5)
       Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore\* using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild
       Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Search paths being used for $(MSBuildExtensionsPath) are C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild;$(MSBuildProgramFiles32)\MSBuild
       Trying to import C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets using extensions path C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild
       Trying to import C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets using extensions path C:\Program Files (x86)\MSBuild
     1>Project "C:\TeamCity\buildAgent\work\DWX_CI\Database\Database.sqlproj" on node 1 (Clean;Build target(s)).
     1>Building with tools version "15.0".
     1>C:\TeamCity\buildAgent\work\DWX_CI\Database\Database.sqlproj(66,57): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Also, tried to find "Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\MSBuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
     1>Done Building Project "C:\TeamCity\buildAgent\work\DWX_CI\Database\Database.sqlproj" (Clean;Build target(s)) -- FAILED.

Build FAILED.

       "C:\TeamCity\buildAgent\work\DWX_CI\Database\Database.sqlproj" (Clean;Build target) (1) ->
         C:\TeamCity\buildAgent\work\DWX_CI\Database\Database.sqlproj(66,57): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Also, tried to find "Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\MSBuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.30

The path "C:\Program Files (x86)\Microsoft Visual Studio\2017" contains two folders 'BuildTools' and 'SQL'. SQL folder was created by SSDT installer and as expected it contains SSDT tools. Manually using msbuild located in SQL folder correctly builds the database project.

Before migrating to gulp, we used grunt with grunt-msbuild plugin. Inernally it uses vswhere utility which correctly used msbuild from SQL folder.

I noticed that msbuild-finder.js only looks in

var possibleFolders = ['BuildTools', 'Enterprise', 'Professional', 'Community'];

xbuild does not support the `/maxcpucount` switch

If you try to run xbuild with the /maxcpucount switch, the following error is thrown:

MSBUILD: error MSBUILD0004: Too many project files specified

We need to make sure this switch doesn't get included in the command line arguments when using xbuild.

Error: no writecb in Transform class

After upgrading from 0.2.20 to 0.4.7, my gulp script crashes with an unhandled exception:

Unhandled exception has occurred: Error
Error: no writecb in Transform class
    at afterTransform (f:\git\devcore\src\Node\node_modules\readable-stream\lib\_stream_transform.js:75:33)
    at TransformState.afterTransform (f:\git\devcore\src\Node\node_modules\readable-stream\lib\_stream_transform.js:59:12)
    at f:\git\devcore\src\Node\node_modules\gulp-msbuild\index.js:47:14
    at ChildProcess.<anonymous> (f:\git\devcore\src\Node\node_modules\gulp-msbuild\lib\msbuild-runner.js:57:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

This is my gulp task:

gulp.task('signAndLocalizeNode', ['buildNode', 'browserify'], function () {
    // We only sign on our Windows build box
    if (process.platform !== 'win32') {
        return;
    }
    var options = {
        targets: ['Build'],
        toolsVersion: 15.0,
        properties: {},
        nodeReuse: false,
        logCommand: false,
        stdout: false,
        stderr: true
    };
    if (cmdLine.argv.testSign) {
        options.properties.signtype = 'test';
    }
    if (cmdLine.argv.locType) {
        options.properties.locType = cmdLine.argv.locType;
        options.properties.loclanguages = 'VS';
    }
    if (Debug_1.Debug.diagVerbosityIsAtLeast(Debug_1.Debug.DebVerbosityOpt)) {
        options.logCommand = true;
        options.stdout = true;
    }
    var deferrer = q.defer();
    gulp.src('./MicroBuildSigning.sln')
        .pipe(msbuild(options))
        .on('end', function () {
        deferrer.resolve(null);
    });
    return deferrer.promise
        .then(function () {
        return gulp.src(config.allDefaultResourceJson, { base: config.tsOutputPath })
            .pipe(nls.createAdditionalLanguageFiles(config.supportedLanguages, config.localizationPath))
            .pipe(gulp.dest(config.tsOutputPath));
    });
});

Adding msbuild logging parameter

Hi, just starting to use the tool but would love a couple things added if possible.

  1. Support for build logging, turning on the log and optionally setting the name ie) /flp:logfile=MyProjectOutput.log
  2. An option to show the actual msbuild command that will be executed (for debugging purposes)

XBuild error

Using the code below, I receive the following error:

{ [Error: Command failed: /bin/sh: Build: command not found ] killed: false, code: 127, signal: null }
  return gulp.src(projects) //variable that points to solution/projects
    .pipe(msbuild({
      configuration: configuration, //variable that points to either Debug or Release
      targets: ["Clean", "Build"],
      errorOnFail: true,
      stdout: true
    }));

I only see this error on my Mac. I do not have this issue on Windows. Any idea what's the issue?

Gulp stream does not return if there are no errors and emitPublishedFiles: false

The addition of the "emitPublishedFiles" option has broken our gulp pipeline.

gulp-msbuild is called as follows:

gulp.task('msbuild:build', function() {
	console.log(gutil.colors.cyan('Starting MSBuild'));
	
	return gulp
        .src('*.sln')
        .pipe(msbuild({
            targets: ['Clean', 'Build'],
            configuration: settings.build.PROFILE,
            toolsVersion: process.platform === 'win32' ? 14.0 : 15.0,
            logCommand: true,
            errorOnFail: true,
            stdout: settings.build.DEBUG,
            consoleLoggerParameters: 'ErrorsOnly'
        }));
});

The gulp output shows:

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.61
[14:39:27] MSBuild complete!
[14:39:27] The following tasks did not complete: docker:default, build, msbuild:build
[14:39:27] Did you forget to signal async completion?

This is due to change #57 - since emitPublishedFiles is false by default, the execution never reaches return callback().

We can work around this by forcing return callback() to always be called or by setting emitPublishedFiles to true.

Please make "targets" optional

I've just discovered that these two options are incompatible with each other:

%msbuild% /t:Publish /p:DeployOnBuild=true
==> There is a circular dependency in the target dependency graph involving target "Publish"

This works:
%msbuild% /t:Publish

And this works:
%msbuild% /p:DeployOnBuild=true /p:PublishProfile=MyProfile.pubxml

Notice that the /target option isn't part of this. But msbuild-command-builder.js (line 11) requires a targets option, and will error if undefined.

I have found this as a workaround for the time being:
%msbuild% /t:Build /p:DeployOnBuild=true /p:PublishProfile=MyProfile.pubxml

The fix, I believe, is to change line 11 to:
if (options.targets) { args.push('/target:' + options.targets.join(';')); }

Better way to find msbuild

['-latest', '-products', '*', '-requires', 'Microsoft.Component.MSBuild'],

A better approach to finding the msbuild executable are these options voor vswhere.exe:
['-latest', 'requires', 'Microsoft.Component.MSBuild', '-find', 'MSBuild**\Bin\MSBuild.exe'].

stdout maxbuffer exceeded error

Hi,

When setting the verbosity of msbuild output to something else then quiet or minimum my build fails most of the time returning a 'stdout maxbuffer exceeded' error because it outputs too much data. Unfortunately i need this data to diagnose any issues or build errors/warnings. Is this something that can/needs to be fixed inside gulp-msbuild? Apparently the default buffer size is used: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
SaschaGalley/grunt-phpunit#29 (similar issue)

Thanks in advance

Incorrect architecture check (x86|x64)

It's not you, it's node.

Long story short: os.arch doesn't report the architecture of the processor, but the architecture node runs in. So if you're running node for x86 on an x64 system, os.arch will report ia32. This was the case for my (appveyor)[http://www.appveyor.com] build.

You can fix this by not using os.arch, but by checking for the existence of the c:\Program Files (x86)\ directory. If it exists, you'll need to look for MsBuild there, otherwise it'll be in c:\Program Files\.

You can use the same check to switch between Framework and Framework64

Idea: Providing the assemblies built by the solution as gulp output stream

I know this is possible using an MSBuild targets file but not sure if you can get this from the msbuild exe or not somehow.

In my existing targets file (the one I'm hoping to eliminate by using gulp) I have the following for my build task:

<Target Name="Build">
    <Message Text="Building projects ... " />
    <MSBuild Projects="@(ProjectToBuild)" Targets="Build" Properties='DefineConstants=DINVERSION="$(DINVersion)"'>
        <Output
            TaskParameter="TargetOutputs"
            ItemName="AssembliesBuiltBySolution" />
    </MSBuild>
</Target>

Basically at the end of the build, I get a named output 'AssembliesBuiltBySolution' that I can then copy to another path using this in another target:

<!-- Copy dll's -->
<Copy SourceFiles="@(AssembliesBuiltBySolution)" DestinationFolder="$(TempPath)"  />

I am thinking that in 'gulp thinking', I should be able to just pipe that file list to a destination and that would be it.

Is this even possible do you think?

Build fails on Mac when Visual Studio for Mac installed

After some time away from my Xamarin project, I had to upgrade to Visual Studio for Mac from Xamarin Studio after Microsoft purchased Xamarin. I can do a normal build in VS Mac for my Android project but when I do it through the gulp task I'm getting a null object reference on the build. If I do a command line build using msbuild the project builds fine but the gulp task is using xbuild still and I'm not sure if it should be in this instance.

I build with diagnostic logging and I'm getting the following. I'm wondering if xbuild can deal with .NETStandard targets or not yet and if that is the culprit. Is there a way to force the task to using msbuild and not xbuild?

/Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: Importing project /Users/Richard/Projects/MyCompany/Client/Client.social/packages/NETStandard.Library.2.0.0/build/netstandard2.0/NETStandard.Library.targets
/Users/Richard/Projects/MyCompany/Client/Client.social/packages/NETStandard.Library.2.0.0/build/netstandard2.0/NETStandard.Library.targets: Importing project /Users/Richard/Projects/MyCompany/Client/Client.social/packages/NETStandard.Library.2.0.0/build/NETStandard.Library.targets
/Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: error : /Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: Object reference not set to an instance of an object
/Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: Microsoft.Build.BuildEngine.InvalidProjectFileException: /Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: Object reference not set to an instance of an object ---> System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Build.BuildEngine.Project.GetMetadataBatched (System.String itemName, System.String metadataName) [0x00005] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.MetadataReference.ConvertToString (Microsoft.Build.BuildEngine.Project project, Microsoft.Build.BuildEngine.ExpressionOptions options) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ExpressionCollection.ConvertToString (Microsoft.Build.BuildEngine.Project project, Microsoft.Build.BuildEngine.ExpressionOptions options) [0x0003b] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ExpressionCollection.ConvertToNonArray (Microsoft.Build.BuildEngine.Project project, System.Type type, Microsoft.Build.BuildEngine.ExpressionOptions options) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ExpressionCollection.ConvertTo (Microsoft.Build.BuildEngine.Project project, System.Type type, Microsoft.Build.BuildEngine.ExpressionOptions options) [0x00048] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Expression.ConvertTo (Microsoft.Build.BuildEngine.Project project, System.Type type, Microsoft.Build.BuildEngine.ExpressionOptions options) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Expression.ConvertTo (Microsoft.Build.BuildEngine.Project project, System.Type type) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ConditionFactorExpression.EvaluateToken (Microsoft.Build.BuildEngine.Token token, Microsoft.Build.BuildEngine.Project context) [0x00012] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ConditionFactorExpression.StringEvaluate (Microsoft.Build.BuildEngine.Project context) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ConditionFactorExpression.CanEvaluateToNumber (Microsoft.Build.BuildEngine.Project context) [0x0001e] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ConditionRelationalExpression.BoolEvaluate (Microsoft.Build.BuildEngine.Project context) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.ConditionParser.ParseAndEvaluate (System.String condition, Microsoft.Build.BuildEngine.Project context) [0x0002a] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.BuildItem.Evaluate (Microsoft.Build.BuildEngine.Project project, System.Boolean evaluatedTo) [0x0004c] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.BuildItemGroup.Evaluate () [0x00067] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.GroupingCollection.EvaluateBuildItemGroup (Microsoft.Build.BuildEngine.BuildItemGroup big) [0x00024] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.GroupingCollection.Evaluate (Microsoft.Build.BuildEngine.EvaluationType type) [0x0006a] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.GroupingCollection.Evaluate () [0x00007] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Project.Evaluate () [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Project.ProcessXml () [0x000c3] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Project.DoLoad (System.IO.TextReader textReader) [0x000fe] in <3fff3dadca4b41aeb5fd775f03958c20>:0
--- End of inner exception stack trace ---
at Microsoft.Build.BuildEngine.Project.DoLoad (System.IO.TextReader textReader) [0x0012f] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Project.Load (System.String projectFileName, Microsoft.Build.BuildEngine.ProjectLoadSettings projectLoadSettings) [0x00123] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Project.Load (System.String projectFileName) [0x00000] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal (System.String projectFile, System.String[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags, System.String toolsVersion) [0x0009f] in <3fff3dadca4b41aeb5fd775f03958c20>:0
at Microsoft.Build.BuildEngine.Engine.BuildProjectFile (System.String projectFile, System.String[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags, System.String toolsVersion) [0x00008] in <3fff3dadca4b41aeb5fd775f03958c20>:0
Target performance summary:

Tasks performance summary:

Build FAILED.
Errors:

/Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: error : /Users/Richard/Projects/MyCompany/Client/Client.social/Client.Social.Android/Client.Social.Android.csproj: Object reference not set to an instance of an object

Xbuild on iOS, weird error

Error: Command failed: /bin/sh -c "xbuild" "/Users/Richard/Projects/Company/marsh/marsh.social/Marsh.Social.sln" "/target:Clean;Build" /verbosity:normal /toolsversion:12.0 /nologo /flp:LogFile=build/logs/iOS.Build.log;Append;Verbosity=diagnostic /property:Configuration="Release" /property:Platform="iPhone" /property:BuildIpa="true"
/bin/sh: Append: command not found
/bin/sh: /property:Configuration=Release: No such file or directory

I'm getting this error after the build successfully runs through the gulp task. It's almost like there is extra commands in the stream after the build task runs and they are trying to execute. If I copy/paste that command into a command window and run it I get the same thing.

Here is my gulp task:

gulp.task('build-ios', function() {
    return gulp
        .src('Marsh.Social.sln')
        .pipe(msbuild({
            toolsVersion: 12.0,
            targets: ['Clean', 'Build'],
                        properties: { Configuration: 'Release', Platform: 'iPhone', BuildIpa: 'true' },
            errorOnFail: true,
                        fileLoggerParameters: 'LogFile=build/logs/iOS.Build.log;Append;Verbosity=diagnostic',
            stdout: true
        }));
});

Option to suppress 'maxcpucount' output

It'd be great to have an option to suppress the logging of the 'maxcpucount' option.

In the code here:

  // xbuild does not support the `maxcpucount` argument and throws if provided
  if (options.maxcpucount >= 0 && options.msbuildPath !== 'xbuild') {
    if (options.maxcpucount === 0) {
      gutil.log(gutil.colors.cyan('Using automatic maxcpucount'));
      args.push('/maxcpucount');
    } else {
      gutil.log(gutil.colors.cyan('Using maxcpucount: ' + options.maxcpucount));
      args.push('/maxcpucount:' + options.maxcpucount);
    }
  }

Perhaps by default it could be disabled, and then enabled with a verbose flag? It doesn't seem like we log other options, so disabling that logging by default seems reasonable.

The output is causing problems with some of our build tools.

For now, we are working around it by using maxcpucount: -1 as an option, but it's not ideal since it means the maxcpucount value isn't set as an argument.

Thanks!
Bryan

Does this work for .Net Framework 4.6 version

I don't seem to be able to find the VisualStudioVersion property option for the gulp-msbuild

Basicly my visual studio project is using .Net Framework 4.6, so the old msbuild.exe won't work. I have to use the new msbuild that's located at 'C:\Program Files (x86)\MSBUILD\14.0\Bin\MSBuild.exe'

By using this msbuild tool I can build my project successfully

D:\tfs_data\Dev\Development>where msbuild
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe

D:\tfs_data\Dev\Development>msbuild Fti.Infinity.sln /m /t:Build /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0

However I don't seem to be able to build my solution using gulp-msbuild. As I couldn't find a VisualStudioVersion property to pass to the gulp-msbuild module.

I get the below error

[16:17:56] Using gulpfile D:\tfs_data\Dev\Development\gulpfile.js
[16:17:56] Starting 'build'...
[16:17:56] Finished 'build' after 57 μs
[16:18:16] MSBuild failed with code 1!

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

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

`toolsVersion: 15.0` fails to find msbuild, after looking in amd64 folder

In a VS 2017 developer command prompt, I can't get gulp-MSBuild util to find MSBuild.exe. It's on my PATH, but evidently the gulp task doesn't leverage that. My path is:

C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\15.0\bin\MSBuild.exe

I know VS2017 provides a way to find this tool, even if it isn't on the PATH, ideally gulp-MSBuild would use that to find it rather than just checking a few common paths. But short of that, what option can I set to specify the path myself?

does not work with {read: false}

Hi,

In index.js you have the following code:

var stream = through.obj(function(file, enc, callback) {
var self = this;
if (file.isNull()) {
self.push(file);
return callback();
}

you check whether the file.isNull(), which checks whether file.contents is read. For the rest of the code you only need file.path however.

The means, this lib works if gulp.src('.sln') is called with default parameters, but does not work when you use gulp.src('.sln', {read: false}) as optimization.

You do not really need to real the sln contents, so it would help to replace the check of file.isNull() with something like: file && file.path.

Hope this helps.

AMD64 MSBuild tools can cause build problems with UWP apps

I've run into an issue trying to build UWP apps with gulp-msbuild 0.5.4. When attempting to build build a UWP app on an x64 system I receive the following build error.

error MSB3816: Loading assembly "C:\Users\user.nuget\packages\runtime.win7-x86.microsoft.netcore.runtime.coreclr\1.0.2\runtimes\win7-x86\native\mscorlib.ni.dll" failed. System.ArgumentException: A BadImageFormatException has been thrown while parsing the signature. This is likely due to lack of a generic context. Ensure genericTypeArguments and genericMethodArguments are provided and contain enough context. ---> System.BadImageFormatException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. An attempt was made to load a program with an incorrect format. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format.

This was reproducible via the command line using the same command that is constructed by the code.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe C:\Projects\test-uwp-app\src\test-uwp-app\test-uwp-app.csproj /target:Restore;Rebuild /verbosity:normal /toolsversion:15.0 /nologo /maxcpucount /property:Configuration=Debug /property:Platform=x86 /property:AppxBundlePlatforms=x86

Removing the amd64 from the path so it would use the x86 tools resolved the issue, and this solution was backed up with this [article from Microsoft](Migrating Your Windows Store App to .NET Native). The relevant information is right at the bottom of the article under Building apps.

Use the x86 build tools that are used by default by Visual Studio. We don't recommend using the AMD64 MSBuild tools, which are found in C:\Program Files (x86)\MSBuild\12.0\bin\amd64; these may create build problems.

Could we get an option that would allow us to specify the tools architecture? I was messing around with this locally and created an option that would allow me to override this, and will probably continue with that so I can get a solution for the short term. In msbuild-finder.js, I've modified lines 164-169 to allow me to override the tools architecture, but it needs some more work before it would be ready to submit.

SolutionPlatform option not defined in constants.

When using the option solutionPlatform, gulp-msbuild throws an exception stating
Message:
Unknown option 'solutionPlatform'!

it appears the solutionPlatform is not defined in the constants.default, so it fails the validation check

Allow multiple instances to run concurrently

Currently, kicking off two tasks that use msbuild can cause the options of the last invocation to affect the first because the global options are modified. Please change the code to use a new extended copy of options with each invocation.

VS 2017 Developer Command Prompt finds msbuild 14.0

Hello,

I'm running gulp-msbuild 0.4.7 which I think was released to fix #52.

Unfortunately I'm still having the same/similar issue:
image

Happy to help diagnose if you can point me to what I should be checking for.

Thanks!

Emit published files on web publish

Hi

Not sure if this is possible, and it's sort of been discussed elsewhere, but would it be possible to emit the published files as a readable stream when you're doing a web publish? This would make this module MUCH more gulp like, because then you could simply call this plugin and pipe it to a destination.

If not (and I realize this is asking a lot), but do you have any idea as to how to wrap this module to accomplish this? I've tried a bunch of times, but I can't seem to figure out how to wait until the publish has finished (by waiting for the stream to emit an end event) before returning the src stream on the publish location. I run into issues because I need to return some sort of stream from within the task, but I can't really return a stream with a gulp.src until the publish has finished, because the globs in the gulp.src are evaluated immediately and they find no files.

Task with 'gulp-msbuild' finishes prematurely when working with multiple project files

Hello! I have the following code in my Gulpfile.js:

gulp.task('clean-win-bin', function (cb) {
    del('bin/win', cb);
});

gulp.task('build-win-executables', ['clean-win-bin'], function () {
    return gulp
        .src('src/natives/**/*.csproj')
        .pipe(msbuild({
            targets: ['Clean', 'Build'],
            errorOnFail: true
        }));
});

gulp.task('copy-win-executables', ['build-win-executables'], function () {
    return gulp
        .src([
            'src/natives/**/win/bin/Release/*.exe',
            'src/natives/**/win/bin/Release/*.config'
        ])
        .pipe(flatten())
        .pipe(gulp.dest('bin/win'));
});

There is some (about 5) *.proj files in subdirectories of 'src/natives/'. When I use gulp, it shows that msbuild finish the build-win-executables task just after the first file was processed:

[18:23:44] Using gulpfile Gulpfile.js
[18:23:44] Starting 'clean-win-bin'...
[18:23:44] Finished 'clean-win-bin' after 10 ms
[18:23:44] Starting 'build-win-executables'...
[18:23:44] MSBuild complete!
[18:23:44] Finished 'build-win-executables' after 343 ms
[18:23:44] Starting 'copy-win-executables'...
[18:23:44] Finished 'copy-win-executables' after 52 ms
[18:23:45] MSBuild complete!
[18:23:45] MSBuild complete!
[18:23:46] MSBuild complete!
[18:23:46] MSBuild complete!
[18:23:46] MSBuild complete!

Process finished with exit code 0

I'm not an expert in gulp 😄 , but I've found that emitting the 'end' of the stream here causes the problem - after I've commented this line, all works as expected:

[18:26:55] Using gulpfile d:\testcafe-browser-natives\Gulpfile.js
[18:26:55] Starting 'clean-win-bin'...
[18:26:55] Finished 'clean-win-bin' after 10 ms
[18:26:55] Starting 'build-win-executables'...
[18:26:55] MSBuild complete!
[18:26:56] MSBuild complete!
[18:26:56] MSBuild complete!
[18:26:56] MSBuild complete!
[18:26:57] MSBuild complete!
[18:26:57] MSBuild complete!
[18:26:57] Finished 'build-win-executables' after 2.63 s
[18:26:57] Starting 'copy-win-executables'...
[18:26:57] Finished 'copy-win-executables' after 42 ms

Process finished with exit code 0
Version info

[email protected] on Windows 10
[email protected]
[email protected]
[email protected]
[email protected]

gulp msbuild isn't considering the preview release of visual studio

I added logCommand: true to my msbuild gulp call and I saw that the command was Using MSBuild command: C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe mysln.sln /target:Build /verbosity:minimal /toolsversion:14.0 /nologo /maxcpucount /property:Configuration=Debug

However, I have the preview release of visual studio 2017 installed and it still used an old version of msbuild

emitPublishedFiles undefined in the documentation

Is this an "undocumented feature"? Found it while looking in msbuild-command-builder.js, along with others:

deployDefaultTarget, webPublishMethod, deleteExistingFiles, findDependencies, publishDirectory

I wrote up this issue mostly because I can't find any documentation on "_FindDependencies".

I see they all get applied as "/property:...", so probably something you might've added for your own purposes, so may not be publicly supported. I'll probably work around this using the customArgs portion.

dll cannot be copied because it is used by another process

This is definitely not a new issue but lately the success rate of running a gulp task to build my app is lower than 10% (same rate when build on server). Every time we see different dll(s) is/are having this issue. Please help and none of the suggestion on stackoverflow seems to help.

My app is a website built in c# asp.net MVC using VS2017, I have 30~ish projects under the solution and each time the build fails is because those dll(s) is used by one of the projects.

MSBuild\Microsoft\VisualStudio\v14.0\Web\Deploy\Microsoft.Web.Publishing.Deploy.FileSystem.targets(96,5) trys to copy the following dlls and ran into such problem:

Newtonsoft.Json.dll
Microsoft.CodeAnalysis.VisualBasic.dll
System.Collections.Immutable.dll

I know this plugin is no longer been maintained but would still appreciate any help for this issue.

remove extra msbuild command line attributes

In relations to issue #27 I am finding that the suggestion provided somewhat works.

When I try run this commend via Gulp

return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "project" },
            logCommand: true
            })
        );

The log command is:
xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

This does not actually publish the code.

I tied running this command directly into MSBuild on my PC:
msbuild project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

And it ERRORS out on the publish. I then manually modified the string and test again. I removed the target, verbosity, toolversion nologo manulaly and tried again.
msbuild project.sln /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

And it worked GREAT from the PC directly using msbuild.

So is there a way to remove the extra parameters from the command that is sent via your plugin?

i.e. I would like see if:
xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

is changed to this works:
xbuild /Users/sethk/Documents/workspace/project/project.sln /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

Thoughts?

spawn xbuild ENOENT (Gulp on a Mac)

I just installed gulp-msbuild in my Gulp project on my Mac.
I have a Window 7 VM running IIS and Visual Studio 2015
My code is hosted on my Mac

Normally I log into my VM and do a build via VS15 or MSBuild from the command line. I am trying to setup a system where I never have to log into the VM and I think gulp-msbuild is my solution.

Here is my gulp code, below is my error.

GULP

gulp.task('msbuild', () => {
    return gulp.src(config.env.build)
        .pipe(msbuild({
            customArgs: ['/p:DeployOnBuild=true /p:PublishProfile=MyProject'],
            logCommand: true
            })
        );
});

ERROR

[14:44:23] Using MSBuild command: xbuild /Users/sethk/Documents/workspace/project.sln /target:Rebuild /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=MyProject
[14:44:23] { [Error: spawn xbuild ENOENT]
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn xbuild',
  path: 'xbuild',
  spawnargs: 
   [ '/Users/sethk/Documents/workspace/project.sln',
     '/target:Rebuild',
     '/verbosity:normal',
     '/toolsversion:4.0',
     '/nologo',
     '/property:Configuration=Release',
     '/p:DeployOnBuild=true /p:PublishProfile=MyProject' ] }
[14:44:23] MSBuild failed!
[14:44:23] MSBuild failed with code -2!
[14:44:23] 'msbuild' errored after 35 ms

Is there something I am doing wrong or will this plugin only work while running gulp on the PC?

Default path to msbuild no longer valid after VS2017 install

After installing VS2017, the path to msbuild seems to have changed, resulting in:

Error: spawn C:\WINDOWS\microsoft.net\Framework64\vundefined\msbuild.exe ENOENT
    at exports._errnoException (util.js:1012:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
    at onErrorNT (internal/child_process.js:348:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

This seem to be because its falling back to the windows folder because the latest framework version (15), doesn't have an MSBuild.exe under C:\Program Files\MSBuild\15.0:

$ du -a /c/Program\ Files\ \(x86\)/MSBuild/15.0/
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1028/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1028/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1028
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1031/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1031/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1031
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1033/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1033/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1033
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1036/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1036/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1036
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1040/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1040/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1040
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1041/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1041/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1041
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1042/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1042/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1042
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1049/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1049/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/1049
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/2052/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/2052/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/2052
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/3082/FileTracker32UI.dll
24      /c/Program Files (x86)/MSBuild/15.0/FileTracker/3082/FileTracker64UI.dll
48      /c/Program Files (x86)/MSBuild/15.0/FileTracker/3082
232     /c/Program Files (x86)/MSBuild/15.0/FileTracker/FileTracker32.dll
296     /c/Program Files (x86)/MSBuild/15.0/FileTracker/FileTracker64.dll
1012    /c/Program Files (x86)/MSBuild/15.0/FileTracker
1012    /c/Program Files (x86)/MSBuild/15.0/

This appears to be a new VS2017 issue and frankly after reading the documentation, I'm not actually sure what the correct behaviour even should be, but if you want to track it, there are a bunch of people talking about the issue here:

...for now, I've just uninstalled VS2017 to remove the '15' framework version to get things working again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.