nforgeio / RaspberryDebugger

Visual Studio Extension to Debug C# on Raspberry Pi
Apache License 2.0
39 stars 12 forks source link

Build/publish fails when projects are still loading #21

Closed LwServices closed 3 years ago

LwServices commented 3 years ago

After update to 0.6 try to verify changes. Now its look like this Extension don't work at all.

image

I already tried to -different Project (what worked yesterday) -clean solution -restart visual studio / pc

How I can enable the log for RaspberryDebugger? Where is the log located?

jefflill commented 3 years ago

The debugger just writes to Visual Studio's Output (Debug) pane:

image

Please let me know what you find. The extension should write the stdout/stderr output from the dotnet publish operation to the output pane when the tool returns a non-zero exit code.

I did just notice that projects in solution folders still aren't working and I'll have a look at that.

jefflill commented 3 years ago

I'm poking around on this and am seeing some odd behavior. On my machine this this mostly works but occasionally doesn't. I'm going to investigate further, This has the feel of a cross-threading problem, but we'll see...

jefflill commented 3 years ago

I might be narrowing this down a bit. This seems to be a problem while Visual Studio is executing background tasks just after being launched. I'm seeing three different behaviors:

  1. If you click the Start debugging button as soon as it appears after launching Visual Studio, I generally see the project being launched locally on the development workstation (not on the Raspberry). The root cause here is that Visual Studio is loading extensions asynchronously and the Raspberry Debugger extension hasn't been loaded yet so it can't intercept the run command.

  2. If I wait a bit after launching Visual Studio and opening the solution and start debugging after our extension has been loaded but before Visual Studio reports that the projects are loaded and ready, I see System.AccessViolationException exceptions.

  3. If I wait for Visual Studio to complete all of its background tasks after launching, Raspberry debugging seems to work every time.

These might be of some help:

https://docs.microsoft.com/en-us/visualstudio/extensibility/managing-project-loading-in-a-solution?view=vs-2019 https://www.visualstudiogeeks.com/blog/visual%20studio%20extensibility/how-to-monitor-solution-events-in-vs-extensions https://devblogs.microsoft.com/visualstudio/async-loaded-net-projects-may-impact-visual-studio-extensions/

jefflill commented 3 years ago

It looks like this is fixed. I was able to reproduce this consistently by:

  1. Launch the extension in the debugger
  2. Wait for VS to display it's Getting Started dialog
  3. Wait 20 seconds to give VS a chance to load our extension
  4. Open the test solution and then press F5 as soon you can to initiate the build/publish/debug

I'd see various bad things happen here, including:

I resolved this by ensuring that the projects are fully loaded within our DebugStartCommand via the SVsSolution.EnsureProjectIsLoaded() service method. After this change, I'm unable to reproduce the problem by following the steps above.

jefflill commented 3 years ago

FIXED for v1.1