@@ -374,6 +374,15 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
374374
375375 if ( o . NanoDevice )
376376 {
377+ // check for invalid options passed with nano device operations
378+ if ( o . Platform . HasValue
379+ || ! string . IsNullOrEmpty ( o . TargetName ) )
380+ {
381+ _exitCode = ExitCodes . E9000 ;
382+ _extraMessage = "Incompatible options combined with --nanodevice." ;
383+ return ;
384+ }
385+
377386 var manager = new NanoDeviceManager ( o , _verbosityLevel ) ;
378387
379388 // COM port is mandatory for nano device operations
@@ -412,8 +421,16 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
412421
413422 // if a target name was specified, try to be smart and set the platform accordingly (in case it wasn't specified)
414423 if ( o . Platform == null
415- && ! string . IsNullOrEmpty ( o . TargetName ) )
424+ && ! string . IsNullOrEmpty ( o . TargetName ) )
416425 {
426+ // check for invalid options passed with platform option
427+ if ( o . NanoDevice )
428+ {
429+ _exitCode = ExitCodes . E9000 ;
430+ _extraMessage = "Incompatible options combined with --platform." ;
431+ return ;
432+ }
433+
417434 // easiest one: ESP32
418435 if ( o . TargetName . StartsWith ( "ESP" )
419436 || o . TargetName . StartsWith ( "M5" )
@@ -496,7 +513,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
496513 }
497514 // ESP32 related
498515 else if (
499- ! string . IsNullOrEmpty ( o . SerialPort ) &&
516+ ! string . IsNullOrEmpty ( o . SerialPort ) &&
500517 ( ( o . BaudRate != 921600 ) ||
501518 ( o . Esp32FlashMode != "dio" ) ||
502519 ( o . Esp32FlashFrequency != 40 ) ) )
0 commit comments