@@ -562,11 +562,21 @@ export class WindowsProjectService
562562 "--input" , path . join ( appProjectDir , "app" ) ,
563563 "--output" , path . join ( appProjectDir , "app.nsbundle" ) ,
564564 ] ;
565- // Without a user key, seal with a fresh per-build key the app template embeds.
566- const keyArgs = keyHex ? [ "--key-hex" , keyHex ] : [ "--write-key" , keyPath ] ;
567565 this . $logger . info ( `Running nsbundle_pack (source protection): ${ packExe } ` ) ;
568566 try {
569- const spawnOptions = { cwd : platformData . projectRoot } ;
567+ const spawnOptions : any = { cwd : platformData . projectRoot } ;
568+ // Without a user key, seal with a fresh per-build key the app template embeds.
569+ let keyArgs = [ "--write-key" , keyPath ] ;
570+ if ( keyHex ) {
571+ // command lines show up in process lists and audit logs; older tools only take --key-hex
572+ const help = await this . $childProcess . spawnFromEvent ( packExe , [ "--help" ] , "close" , spawnOptions , { throwError : false } ) ;
573+ if ( / N S _ B U N D L E _ K E Y _ H E X / . test ( `${ help ?. stdout } ${ help ?. stderr } ` ) ) {
574+ keyArgs = [ ] ;
575+ spawnOptions . env = { ...process . env , NS_BUNDLE_KEY_HEX : keyHex } ;
576+ } else {
577+ keyArgs = [ "--key-hex" , keyHex ] ;
578+ }
579+ }
570580 let result = await this . $childProcess . spawnFromEvent ( packExe , [ ...args , ...keyArgs ] , "close" , spawnOptions , { throwError : false } ) ;
571581 if ( ! keyHex && result && result . exitCode !== 0 && / - - w r i t e - k e y / . test ( result . stderr || "" ) ) {
572582 // A framework from before per-build keys: seal with its shared default key.
0 commit comments