Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch.json: "${command:pickProcess}" prompts for a process to attach to *before* running pre-launch tasks #75604

Closed
mklement0 opened this issue Jun 16, 2019 · 5 comments
Assignees
Labels
*as-designed Described behavior is as designed debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@mklement0
Copy link
Contributor

mklement0 commented Jun 16, 2019

As of VSCode v1.35.1, a launch configuration defined in launch.json that uses "${command:pickProcess}" as its "processId" value - in order to prompt for a process to attach to - does so before running any pre-launch tasks (preLaunchTask property).

  • Is this by design?
  • Is there a way to reverse this order?

The reason I want my prelaunch task to run first is twofold:

  • generally, since my prelaunch task includes building, I want the launch to be aborted if building fails.

  • specifically, my prelaunch task creates the process that I then want to attach to.

Taking a step back, my ideal solution would be to have the prelaunch task not only create the process to attach to, but to have the launch configuration automatically attach to it afterwards, but I haven't found a way to do that, given that:

  • starting the debugger from the command line isn't supported yet - though support is being considered - see Suggestion: Start VSCode debugger from the command-line #10979

  • there seems to be no way to populate a launch-configuration property from an arbitrary shell command (you can only call VSCode-internal commands via ${command:...}).

Note: I hit this limitation when trying to debug binary PowerShell modules via an external PowerShell console. I've since realized that the C# debugger automatically attaches to any external process created via a "request": "launch" launch configuration, so launching a PowerShell console that way (with a startup command that imports the binary module) is sufficient.

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jun 16, 2019
@RandomGHUser
Copy link

RandomGHUser commented Jul 30, 2019

I too am having this exact same problem. I would expect my prelaunch task (which stops my remote process, builds and pushes my project to the remote box, then restarts the remote process) to finish executing before picking the process to attach to.

There are easy enough workarounds, but it should be able to work with a single launch configuration.

@weinand
Copy link
Contributor

weinand commented Oct 16, 2019

@isidorn what is the order of resolving variables and running the prelaunch task?

@weinand weinand added the under-discussion Issue is under discussion for relevance, priority, approach label Oct 16, 2019
@isidorn
Copy link
Contributor

isidorn commented Oct 16, 2019

We first resolve the varialbes and then run the preLaunchTask. Code pointer

@weinand
Copy link
Contributor

weinand commented Oct 16, 2019

this makes sense because the "preLaunchTask" attribute could contain a variable too.
So this works as designed.

@weinand weinand closed this as completed Oct 16, 2019
@weinand weinand added *as-designed Described behavior is as designed and removed under-discussion Issue is under discussion for relevance, priority, approach labels Oct 16, 2019
@mklement0
Copy link
Contributor Author

Understood re current design, but I think there is a usability issue here:

It doesn't make sense to pick a process first, if the pre-launch task can fail.

I understand that variable resolution coming first is what triggers the untimely prompting, but I wonder if an exception can be made in this case: defer any "${command:pickProcess}" actions until after the pre-launch tasks have run successfully.

If not all cases of untimely prompts can reliably be inferred (given that there can be arbitrary extension-supplied commands such as extension.pickNodeProcess), perhaps an opt-in property could solve the problem.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

4 participants