@@ -170,6 +170,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
170
170
notification : msg
171
171
} ) ;
172
172
}
173
+
174
+ this . handleDeveloperDiskImageError ( err , liveSyncResultInfo , projectData , debugOpts , outputPath ) ;
173
175
}
174
176
175
177
this . emitLivesyncEvent ( LiveSyncEvents . liveSyncExecuted , {
@@ -183,41 +185,26 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
183
185
184
186
private async refreshApplicationWithDebug ( projectData : IProjectData , liveSyncResultInfo : ILiveSyncResultInfo , debugOptions : IDebugOptions , outputPath ?: string ) : Promise < IDebugInformation > {
185
187
const deviceAppData = liveSyncResultInfo . deviceAppData ;
188
+ debugOptions = debugOptions || { } ;
186
189
187
190
const deviceIdentifier = liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ;
188
191
await this . $debugService . debugStop ( deviceIdentifier ) ;
189
192
this . emit ( DEBUGGER_DETACHED_EVENT_NAME , { deviceIdentifier } ) ;
190
193
191
- const applicationId = deviceAppData . appIdentifier ;
192
- const attachDebuggerOptions : IAttachDebuggerOptions = {
193
- platform : liveSyncResultInfo . deviceAppData . device . deviceInfo . platform ,
194
- isEmulator : liveSyncResultInfo . deviceAppData . device . isEmulator ,
195
- projectDir : projectData . projectDir ,
196
- deviceIdentifier,
197
- debugOptions,
198
- outputPath
199
- } ;
200
194
201
- try {
202
- await deviceAppData . device . applicationManager . stopApplication ( { appId : applicationId , projectName : projectData . projectName } ) ;
203
- // Now that we've stopped the application we know it isn't started, so set debugOptions.start to false
204
- // so that it doesn't default to true in attachDebugger method
205
- debugOptions = debugOptions || { } ;
206
- debugOptions . start = false ;
207
- } catch ( err ) {
208
- this . $logger . trace ( "Could not stop application during debug livesync. Will try to restart app instead." , err ) ;
209
- if ( ( err . message || err ) === "Could not find developer disk image" ) {
210
- // Set isFullSync here to true because we are refreshing with debugger
211
- // We want to force a restart instead of accidentally performing LiveEdit or FastSync
212
- liveSyncResultInfo . isFullSync = true ;
213
- await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , debugOptions , outputPath , { shouldSkipEmitLiveSyncNotification : true } ) ;
214
- this . emit ( USER_INTERACTION_NEEDED_EVENT_NAME , attachDebuggerOptions ) ;
215
- return ;
216
- } else {
217
- throw err ;
195
+ if ( debugOptions . debugBrk ) {
196
+ const applicationId = deviceAppData . appIdentifier ;
197
+ try {
198
+ await deviceAppData . device . applicationManager . stopApplication ( { appId : applicationId , projectName : projectData . projectName } ) ;
199
+ } catch ( err ) {
200
+ this . $logger . trace ( "Could not stop application during debug livesync. Will try to restart app instead." , err ) ;
201
+ this . handleDeveloperDiskImageError ( err , liveSyncResultInfo , projectData , debugOptions , outputPath ) ;
218
202
}
203
+ } else {
204
+ await this . refreshApplicationWithoutDebug ( projectData , liveSyncResultInfo , debugOptions , outputPath , { shouldSkipEmitLiveSyncNotification : true } ) ;
219
205
}
220
206
207
+ debugOptions . start = ! debugOptions . debugBrk ;
221
208
const deviceOption = {
222
209
deviceIdentifier : liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ,
223
210
debugOptions : debugOptions ,
@@ -226,6 +213,21 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
226
213
return this . enableDebuggingCoreWithoutWaitingCurrentAction ( deviceOption , { projectDir : projectData . projectDir } ) ;
227
214
}
228
215
216
+ private handleDeveloperDiskImageError ( err : any , liveSyncResultInfo : ILiveSyncResultInfo , projectData : IProjectData , debugOpts : IDebugOptions , outputPath : string ) {
217
+ if ( ( err . message || err ) === "Could not find developer disk image" ) {
218
+ const deviceIdentifier = liveSyncResultInfo . deviceAppData . device . deviceInfo . identifier ;
219
+ const attachDebuggerOptions : IAttachDebuggerOptions = {
220
+ platform : liveSyncResultInfo . deviceAppData . device . deviceInfo . platform ,
221
+ isEmulator : liveSyncResultInfo . deviceAppData . device . isEmulator ,
222
+ projectDir : projectData . projectDir ,
223
+ deviceIdentifier,
224
+ debugOptions : debugOpts ,
225
+ outputPath
226
+ } ;
227
+ this . emit ( USER_INTERACTION_NEEDED_EVENT_NAME , attachDebuggerOptions ) ;
228
+ }
229
+ }
230
+
229
231
public async attachDebugger ( settings : IAttachDebuggerOptions ) : Promise < IDebugInformation > {
230
232
// Default values
231
233
if ( settings . debugOptions ) {
0 commit comments