Search code examples
c#asp.net-coredebugging

How to Debug a .NET Core Console App When Using dotnet run


So I'm working on a custom dotnet cli tool as described here. I'm getting started with it and can run my console app using dotnet run, but it's going right past my breakpoints when trying to debug. It does work when running from VS, but I want to be able to play around with passing various arguments and doing that from the application arguments box is not really practical. Any thoughts?


Solution

  • For what it's worth, it seems like the best way is unfortunately to pass them in as arguments.

    You can do this by clicking on the arrow next to Run button in Visual Studio and selecting 'Project Debug Properties'. From there, you can go to 'Application Arguments' and enter the arguments you want. For example, something like --list all would pass in an array with a length of two where index 0 is --list and index 1 is all.

    If someone comes up with a less invasive way, let me know!

    Edit: You can also do it from command prompt/powershell by using dotnet run and attaching to the associated process in VS (Debug>Attach to Process)