From 5d0f0b51743f8c2dcc9d374e2b858a4742053e19 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Mon, 25 May 2026 11:11:27 +1200 Subject: [PATCH] fix(nuget): use unique suffix for global.json backup Follow-up to #820. The backup path was a fixed `global.json.craft-bak`, which could theoretically clash if two craft invocations ran against the same working directory. Use `crypto.randomUUID()` to make the suffix unique per invocation. Refs: https://github.com/getsentry/craft/pull/820#discussion_r3287646962 Co-Authored-By: Claude Opus 4.7 --- src/targets/nuget.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/targets/nuget.ts b/src/targets/nuget.ts index ae0f7bb0..a5f471aa 100644 --- a/src/targets/nuget.ts +++ b/src/targets/nuget.ts @@ -6,6 +6,7 @@ import { writeFileSync, } from 'fs'; import { join } from 'path'; +import { randomUUID } from 'crypto'; import { TargetConfig, TypedTargetConfig } from '../schemas/project_config'; import { ConfigurationError, reportError } from '../utils/errors'; @@ -88,7 +89,7 @@ export class NugetTarget extends BaseTarget { // which breaks if the pinned SDK isn't installed on the craft runner. // See: https://github.com/getsentry/craft/issues/819 const globalJsonPath = join(rootDir, 'global.json'); - const globalJsonBackup = `${globalJsonPath}.craft-bak`; + const globalJsonBackup = `${globalJsonPath}.craft-bak-${randomUUID()}`; const globalJsonMoved = existsSync(globalJsonPath); if (globalJsonMoved) { renameSync(globalJsonPath, globalJsonBackup);