When adding this.log to custom subtasks I'm getting the error listed in the title.
v1.9.1 of SPFx.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Could you provide more details?
I did sample test in my local environment while can't reproduce.
`'use strict';
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.);
let helloWorldSubtask = build.subTask('log-hello-world-subtask', function(gulp, buildOptions, done) {
this.log('Hello, World!');
// use functions from gulp task here
done();
});
build.rig.addBuildTasks(helloWorldSubtask);
build.initialize(gulp);
`

Or
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
let helloWorldSubtask = build.subTask('log-hello-world-subtask', function(gulp, buildOptions, done) {
this.log('Hello, World!');
// use functions from gulp task here
done();
});
//build.rig.addBuildTasks(helloWorldSubtask);
// Register the task with gulp command line
let helloWorldTask = build.task('hello-world', helloWorldSubtask);
build.initialize(gulp);`

Lee
Microsoft SharePoint Community Support
Hi @OS-Lee,
Sorry, my bad in initial description. The project is on version 1.8.2.
The code:
'use strict';
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
let updateVersionTask = build.subTask('update-version', (gulp, buildOptions, done) => {
this.log('TEST');
done();
});
build.rig.addPreBuildTask(updateVersionTask);
build.initialize(gulp);
Define the function as
let updateVersionTask = build.subTask('update-version', function(gulp, buildOptions, done){
this.log('TEST');
done();
});
will fix the error based on my testing.
Lee
Microsoft SharePoint Community Support
Yep, arrow function replaces the context! Thanks!
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues