VS Code - Start Debugging - Device Selection

If I select Run > Start Debugging or Run Without Debugging in VS Code 1.63.2 on Mac the first time I can choose a device from the products list.

But if I select Start Debugging or Run Without Debugging the second time it shows no device list and the simulator starts with the last selected device. I have to restart VS Code every time I want to test another device.

The same is true when I choose Run and Debug from the Run and Debug section.

The solution provided in this thread does not work for me: forums.garmin.com/.../general-vs-code-usage-questions

How can I select another device from the products list to run in simulator without restarting VS Code?

  • If you press Ctrl+Shift+P (not sure what the corresponding shortcut is on Mac), you'll see a lot more options than the toolbar shortcuts. There is one called "build project" or something like that (can't remember what's called exactly) that will ask you again for which device. After that, you can just run as usual and the simulator will show the new device.

    If you have trouble finding it, let me know and I can search for the exact name later and post it here.

  • Thanks Felipe. This is the same solution like in this thread: forums.garmin.com/.../1149675

    But it does not work for me. The command is called "Build for Device".

    If I "Build for Device" I can choose a device from the device list and it builds.

    After that I select Run > Start Debugging or Run Without Debugging. I can choose a device from the device list and the simulator starts.

    But if I select Run > Start Debugging or Run Without Debugging the second time I can not choose a device from the device list. It starts the simulator with the same device like last time.

    Same happens if I "Build for Device" again. If I select Run > Start Debugging or Run Without Debugging the third time I can not choose a device from the device list.

    I can not find a way to test different devices after another without restarting VS Code.

    I will attach a screenshot of all Monkey C commands.

  • I think I have now found the solution:

    1. Use the command "Build Current Project"

    2. Than select the device from products list

    3. Than Run > Start Debugging (F5)

    It would be nice to have an option which always brings up the products list without first using the command "Build Current Project".


    Another solution which lets me always choose a device from products list when selecting Run > Start Debugging (F5):

    Comment out line 80 "lastBuildDevice = workspace.getLastBuildDevice();" in runProgram.js file.

    On Mac the file is located here:

    /Users/user/.vscode/extensions/garmin.monkey-c-1.0.1/out/runProgram.js

    + if you want that the last used device is NOT selected in the device list when selecting Run > Start Debugging (F5):

    Change line 36 from

    workspace === null || workspace === void 0 ? void 0 : workspace.setLastBuildDevice(lastBuildDevice);

    to

    workspace === null || workspace === void 0 ? void 0 : workspace.setLastBuildDevice();
     

  • Yes, this is the one I was talking about.

    To be honest, it works fine for me... You build first time, select device and start testing for that device by running N number of times. Once you're done, build current project for the new device and run again until you're finished with that one... And it goes on until you've tested all Smiley

  • It would be nice to have an option which always brings up the products list without first using the command "Build Current Project".

    Yes, Eclipse had the opposite behavior: you couldn't run an app (in a single step) without selecting a device.

    Now with VS Code, you can't run an app (in a single step) *and* select a device (unless you've just opened VS Code).

    But I guess the problem is that neither behavior is suitable for every dev in every situation.

    So maybe it would be nice for the "use last built device" behavior to be an option.