Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

Hambone F
Hambone F
3,581 Points

Gulp Task Is Broken

For anyone watching in 2020 - the Gulp tasks don't work if you are using Node version 12 or higher.

I was ultimately able to resolve this after performing several actions.

  1. Update the gulp to version 4
  2. Edit the default task defition to use Gulp 4 syntax
  3. To use with VS2019 - change the tools version

Updating Gulp

I updated to the latest version of each by editing my package.json to read like this:

  "devDependencies": {
    "gulp": "*",
    "gulp-msbuild": "*",
    "gulp-nuget-restore": "*"
  }

Then ran npm update --save-dev inside the project directory.

After that, my package.json looked like this:

  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-msbuild": "^0.8.0",
    "gulp-nuget-restore": "^0.7.0"
  }

YMMV - you could also potentially use these version numbers directly instead of the '*'

Updating the gulpfile

After doing that, the gulp task still wouldn't load. Turns out that gulp 4 changes the syntax.

This is the only portion that's affected:

gulp.task('default', ['nuget-restore'], function () {
  return gulp.src('../../project.msbuild')
    .pipe(msbuild({
      stdout: true,
      targets: ['Start'],
      toolsVersion: 15,
      verbosity: 'minimal'
    }));
});

Here's the same, with the newer syntax:

gulp.task('default', gulp.series('nuget-restore', function () {
  return gulp.src('../../project.msbuild')
    .pipe(msbuild({
      stdout: true,
      targets: ['Start'],
      toolsVersion: 15,
      verbosity: 'minimal'
    }));
}));

After making this change, finally my gulp tasks were loading in Visual Studio!

Updating for VS2019

Now I had a new error message - MSBuild wouldn't start.

It seems that is due to this gulp file specifically looking for MSBuild 15, however VS2019 ships with a newer version of MSBuild.

I simply changed the toolsVersion to 'auto' - hopefully this would work for future versions of VS as well.

gulp.task('default', gulp.series('nuget-restore', function () {
  return gulp.src('../../project.msbuild')
    .pipe(msbuild({
      stdout: true,
      targets: ['Start'],
      toolsVersion: 'auto',
      verbosity: 'minimal'
    }));
}));

Hopefully you see this if you're having the same issue! This was by far much more difficult than the actual assignment :)