@@ -224,8 +224,12 @@ export class WindowsApplicationManager extends ApplicationManagerBase {
224224 } else {
225225 // PFN already cached from the pre-resolve above; no extra round-trip.
226226 const pfn = this . _packageFamilyNames . get ( appData . appId ) ?? appData . appId ;
227+ // Any debug session starts the inspector; --debug-brk additionally signals break-on-start.
228+ if ( appData . debugMode ) {
229+ this . _writeMarker ( pfn , "ns-inspector" ) ;
230+ }
227231 if ( appData . waitForDebugger ) {
228- this . _writeDebugBreakMarker ( pfn ) ;
232+ this . _writeMarker ( pfn , "ns-debugbreak" ) ;
229233 }
230234 // UWP apps are launched via shell:AppsFolder\<PFN>!<ApplicationId>.
231235 // The ApplicationId comes from the <Application Id="..."> attribute in the manifest.
@@ -320,22 +324,19 @@ export class WindowsApplicationManager extends ApplicationManagerBase {
320324 return this . _packageFamilyNames . get ( appId ) ?? appId ;
321325 }
322326
323- private _writeDebugBreakMarker ( pfn : string ) : void {
327+ // Writes a sentinel file into the packaged app's LocalState that the C# host consumes on launch
328+ // (RuntimeHost.ConsumeMarker). Used to signal the inspector ("ns-inspector") and break-on-start
329+ // ("ns-debugbreak") out-of-band, since a UWP app launched via shell:AppsFolder inherits no env.
330+ private _writeMarker ( pfn : string , name : string ) : void {
324331 const localAppData = process . env . LOCALAPPDATA ;
325332 if ( ! localAppData ) return ;
326- const markerPath = path . join (
327- localAppData ,
328- "Packages" ,
329- pfn ,
330- "LocalState" ,
331- "ns-debugbreak" ,
332- ) ;
333+ const markerPath = path . join ( localAppData , "Packages" , pfn , "LocalState" , name ) ;
333334 try {
334335 fs . mkdirSync ( path . dirname ( markerPath ) , { recursive : true } ) ;
335336 fs . writeFileSync ( markerPath , "" , "utf8" ) ;
336- this . $logger . info ( `[Windows] Debug break marker: ${ markerPath } ` ) ;
337+ this . $logger . info ( `[Windows] Wrote ${ name } marker: ${ markerPath } ` ) ;
337338 } catch ( e ) {
338- this . $logger . warn ( `[Windows] Could not write debug break marker: ${ e } ` ) ;
339+ this . $logger . warn ( `[Windows] Could not write ${ name } marker: ${ e } ` ) ;
339340 }
340341 }
341342}
0 commit comments