Skip to content

Debugging Omnisharp Roslyn with Visual Studio

William Luu edited this page Nov 23, 2016 · 2 revisions

From Dustin Campbell on slack.

(I'll clean this up later and convert it to a proper write up. Just want to save the relevant bits in here first).

danwalmsley [10:08]
do you guys know how I can tell visual studio to launch a process and immediately attach debugger?

danwalmsley [10:08]
rather than me attaching when its already run past the code I need to debug?

dustinc [10:09]
There are a lot of problems with that with the new MSBuild stuff on Windows

dustinc [10:09]
here's the thing

dustinc [10:09]
MSBuild likes to be in the same directory as your application.

dustinc [10:09]
However, when debugging old xproj stuff, it redirects to the MSBuild that is installed in your Nuget folder

dustinc [10:09]
and stuff breaks

dustinc [10:10]
That's what happens on F5 for MSBuild anyway

dustinc [10:10]
So, I tend to do the following.

dustinc [10:11]

  1. Run OmniSharp at the command-line with the arguments I need (e.g. --stdio -s <my project or solution file>). I also include the --debug argument.

dustinc [10:11]
2. Then, I attach Visual Studio to the running OmniSharp.exe.

Note: I run OmniSharp from my artifacts/public/OmniSharp/default/net46 directory

dustinc [10:12]
on Windows

dustinc [10:12]
Reverse the slashes.

danwalmsley [10:12 AM]
What does --debug do?

dustinc [10:13]
It stops OmniSharp from loading until a debugger is attached