2

When learning about .NET Core, I heard that it would be possible to edit .CS code while debugging (e.g. controllers). Now that we're at .NET Core 2, I still can't find a way to get this to work.

This all stems from working with PHP/JavaScript developers who absolutely hate, with reason, the lack of editing while debugging. You have to stop the app, edit the code, run, wait for build, and then see it. I get it's because of the compilation, but I thought they were changing something in .NET Core and VS 2017. This even goes down to stupid things like adding images to your project.

Any ideas on how to enable some of this?

2
  • Have you tried running the app directly instead of inside IIS Express? Open the debug target menu in the toolbar (the green "play" icon), and choose the item that corresponds to your project name. Commented Sep 28, 2017 at 14:45
  • @ChrisPratt Does that work for you? Sounds like it doesn't work based on answer below but just curious if you're saying you can do it. Also, you were great in Guardians of the Galaxy :) Commented Mar 22, 2018 at 19:46

1 Answer 1

4

The answer is yes and no.

There are "watchers" in .NET Core that means your code is constantly recompiled as you make changes. To do this you just add this nuget package :

Install-Package Microsoft.DotNet.Watcher.Tools

And then run the watch command from your command line tool :

dotnet watch run

But again, this is simply recompiling your code as fast as possible so that when you refresh in your browser, the live changes are there. It's similar to other watches in things like Gulp etc.

It's possible to "attach" the debugger to your running instance, but as soon as your code is recompiled you need to reattach the debugger. If you are looking to be able to use breakpoints while using watchers for example, I don't think it's possible.

More info :

https://dotnetcoretutorials.com/2017/01/31/live-coding-net-core-using-dotnet-watch/ https://learn.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch

Sign up to request clarification or add additional context in comments.

1 Comment

So it basically just hits Ctrl-Shift-B for you all the time? Doesn't seem like that much of a feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.