microsoft/typescript-go · error · Error

This task should not be run in release builds.

Error message

This task should not be run in release builds.

What it means

The `native-preview` task is the local/dev aggregate: its dependencies and run function are chosen from `options.forRelease`, and when forRelease is set its run() simply throws — in release mode the correct entry point is `native-preview:release`, which orchestrates build, sign, pack, VSIX, and cleanup with the proper flags. This prevents a release-mode invocation of the dev task from producing unsigned, mis-versioned artifacts.

Source

Thrown at Herebyfile.mjs:2413

    run: async () => {
        if (!options.forRelease || !options.setPrerelease && (!nativePreviewReleaseVersion || produceAnyVsix)) {
            throw new Error("native-preview:release requires --forRelease and --setPrerelease flags, unless nativePreviewReleaseVersion is hardcoded and VSIX production is disabled. Example: npx hereby native-preview:release --forRelease --setPrerelease=dev.1.0");
        }
        await runBuildNativePreviewPackages();
        await runSignNativePreviewPackages();
        await runPackNativePreviewPackages();
        await runPackVsixExtensions();
        await runSignVsixExtensions();
        await runCleanSignTempDirectory();
    },
});

export const nativePreview = task({
    name: "native-preview",
    hiddenFromTaskList: true,
    dependencies: options.forRelease ? undefined : [packNativePreviewPackages, packVsixExtensions],
    run: options.forRelease ? async () => {
        throw new Error("This task should not be run in release builds.");
    } : undefined,
});

export const allChecks = task({
    name: "all-checks",
    description: "Runs all checks for the Go code (fourslash, lint, tests, etc.)",
    run: async () => {
        await $`npm run convertfourslash`;
        await runTests();
        await $`npm run updatefailing`;
        await runFormat();
        await runLint();
        await runTests();
    },
});

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. In release mode, use `npx hereby native-preview:release --forRelease --setPrerelease=dev.N.M` instead
  2. Keep using plain `npx hereby native-preview` only for local, non-release builds
  3. Update scripts/docs so the task name is chosen based on release mode

Example fix

# before
npx hereby native-preview --forRelease --setPrerelease=dev.1.0

# after
npx hereby native-preview:release --forRelease --setPrerelease=dev.1.0
Defensive patterns

Strategy: validation

Validate before calling

const task = forRelease ? "native-preview:release" : "native-preview";
const flags = forRelease ? ["--forRelease", `--setPrerelease=${prerelease}`] : [];
// spawn: npx hereby ${task} ${flags.join(" ")}

Prevention

When it happens

Trigger: Running `npx hereby native-preview --forRelease` (with or without --setPrerelease): the dev task detects release mode and refuses.

Common situations: Muscle-memory reuse of the local task name in a release script; scripts that append --forRelease to whichever native-preview task they find; stale docs referencing the old task name.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/e6561b9fd8774414. Report an issue: GitHub.