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#

[SOLVED] Code Challenge, Visual Studio 2019, and Gulp

I had some problems completing a code challenge for 'Building Services with ASP.NET Web API' and thought I would post my solution to hopefully save others some time.

In short, Visual Studio 2019 is not compatible with the version of Gulp (3.9.1) in the downloaded solution; and updating Gulp breaks the default task in gulpfile.js. So the fix is basically a two-step process: Update the three Gulp packages in package.json (so they're compatible with VS2019) and modify the default task in gulpfile.js (so it's compatible with Gulp 4). However, there are a few other pitfalls that I address below.

Note: You don't need to have Node.js installed for Gulp to do its thing in VS. I confirmed this by performing the steps below on a fresh copy of Windows and VS 2019 with only the 'ASP.Net and web development' workload installed.

Unzip and open the solution. In Solution Explorer, right click the solution, select 'Manage NuGet Packages For Solution', then click the 'Restore' button in the alert section.

IMPORTANT: Do NOT update any NuGet packages. Doing so will break a static reference in the project.msbuild XML file.

Try building the solution. If you receive errors, restart Visual Studio. The solution should then build without issue.

In IssueTracker > package.json, update 'devDependencies' to the latest versions using intellisense (restore preceding '^' if removed). Change the 'name' property to all lowercase and save the file.

Changing and saving the Gulp version numbers causes VS to download the updated packages. At the bottom, you'll see a colliding arrows progress indicator, then 'Installing packages complete' when finished.

After the Gulp package updates complete, open IssueTracker > gulpfile.js and replace the default task with the following code, then save the file.

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

Right-click IssueTracker > gulpfile.js and select Task Runner Explorer. Gulpfile.js should now show as loaded.

Complete the code challenge tasks (observing NuGet package versions) then build the solution.

In Task Runner Explorer, expand Gulpfile.js and Tasks. Right click 'default' and select 'Run'. If you missed anything, it will let you know in the task output.

If all went well, you'll see 'MSBuild complete!' and an uploadable project.zip file will be located in the root folder (which also contains README.md).

Good luck!

Hambone F
Hambone F
3,581 Points

I ultimately went through the same (lengthy!) process by google, trial, and error and wrote up a forum post on this exact same thing - and only after that saw yours!

I just wanted to say - thanks for sharing this!