Reputation: 978
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?
Upvotes: 2
Views: 2082
Reputation: 12470
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
Upvotes: 4