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

Enable coreclr debugger to lunch dotnet commands #252

Closed
troydai opened this issue Apr 27, 2016 · 8 comments
Closed

Enable coreclr debugger to lunch dotnet commands #252

troydai opened this issue Apr 27, 2016 · 8 comments
Labels

Comments

@troydai
Copy link
Contributor

troydai commented Apr 27, 2016

Today to configure the lunch command for coreclr, users can only specify an assembly. dotnet command like dotnet test is not configurable.

This blocks the scenario of run and debugging a dotnet xunit test.

@gregg-miskelly
Copy link
Contributor

  1. dotnet test will not work no matter what - the code you want to debug is in a child process
  2. If you had another app that would work you can do it -- set the 'program' to be what you want to debug (ex: dotnet your case), set args to be any arguments to it.

@troydai
Copy link
Contributor Author

troydai commented Apr 27, 2016

got it. thanks.

@seesharper
Copy link

Does this mean that there is a way to debug xunit tests in VsCode?
Could you elaborate on the following
"If you had another app that would work you can do it -- set the 'program' to be what you want to debug (ex: dotnet your case), set args to be any arguments to it."

@gregg-miskelly
Copy link
Contributor

@seesharper : You can debug any .NET Core RC2+ program you want in VS Code. However, there is no child process debugging. So if the program spawns the code in a child process (like 'dotnet test' does) - it isn't going to work. If you run xunit directly through - yes, that will work.

@seesharper
Copy link

Which would mean invoking the xunit.runner.console.exe directly?

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented May 13, 2016

If xunit.runner.console.exe is a native CoreCLR host (ex: it is just corehost.exe renamed) then yes.

Otherwise - no, you would need to launch some sort of CoreCLR host executable. I am not a super expert on this subject, but the two hosts that come with the .NET CLI are -- 'dotnet.exe ' and corehost.exe. CoreHost.exe works like this - you copy it next to a managed entry point dll (ex: if you want to run c:\example\bin\debug\example.dll, copy it to c:\example\bin\debug\example.exe) it will then look for a dll next to itself. The CLI uses a 'deps' file to use these.

@seesharper
Copy link

Thanks a lot for valuable information. I managed to get it working with a native CoreCLR console app where I simply new up the test classes and manually invoke the test method.

using System;
using Microsoft.Extensions.DependencyInjection.Tests;
namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            ServiceProviderContainerTests t = new ServiceProviderContainerTests(); 
            t.ClosedServicesPreferredOverOpenGenericServices();            
        }
    }
}

This approach is a little cumbersome, but it allows me to "pick" the test method to be executed and I can actually debug the test using vs code. It would be great however, if there was a way to determine the "current" method in the editor. If I knew the name of the test method currently under the cursor I could feed that to the args of my little test wrapper console app (e.g debug current test).
If this is not possible I will at least I have a way to debug tests now. Thanks a lot for your help.

@gregg-miskelly
Copy link
Contributor

We have a feature request (#311) to add proper support for 'dotnet test' which I think will solve your problem. If not, the technique we employ when implementing it, you could probably use in your own VS Code extension if you want. But as of now, I think your solution is the best I can think of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants