diff --git a/common/changes/@microsoft/rush/main_2024-12-13-20-32.json b/common/changes/@microsoft/rush/main_2024-12-13-20-32.json new file mode 100644 index 00000000000..d1962a59d93 --- /dev/null +++ b/common/changes/@microsoft/rush/main_2024-12-13-20-32.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "When a no-op operation is not in scope, reflect its result as no-op instead of skipped, so that downstream operations can still write to the build cache.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/operations/OperationExecutionRecord.ts b/libraries/rush-lib/src/logic/operations/OperationExecutionRecord.ts index 5aa22ef73be..d9c4a2b82a9 100644 --- a/libraries/rush-lib/src/logic/operations/OperationExecutionRecord.ts +++ b/libraries/rush-lib/src/logic/operations/OperationExecutionRecord.ts @@ -313,7 +313,12 @@ export class OperationExecutionRecord implements IOperationRunnerContext, IOpera this.status = earlyReturnStatus; } else { // If the operation is disabled, skip the runner and directly mark as Skipped. - this.status = this.operation.enabled ? await this.runner.executeAsync(this) : OperationStatus.Skipped; + // However, if the operation is a NoOp, return NoOp so that cache entries can still be written. + this.status = this.operation.enabled + ? await this.runner.executeAsync(this) + : this.runner.isNoOp + ? OperationStatus.NoOp + : OperationStatus.Skipped; } // Delegate global state reporting await onResult(this);