Tracking code changes in ASP.NET Core using dotnet-watch

One of the cool feature in ASP.NET 5 (before renaming to ASP.NET Core) or more precisely in dnx was tracking all code changes without recompiling whole project (Microsoft used to call that In-Memory compilation). Why is that so cool? Well simply, it’s way more comfortable than it used to be, and it makes our development faster. Now the good news is that it’s not gone. I mean, if you run your .NET Core application (with Ctrl+F5, not F5) using IIS Express, you can change your code in Visual Studio, then save the file and refresh the browser. Poof, magic! But, the thing is that many developers (including me) launch their apps directly using only Kestrel. You can run that mode in two ways:


  • in the root folder of your app type „dotnet run” command
  • switch that directly in Visual Studio like in the example below:



Now, running that mode will prevent using In-Memory Compilation…and that sucks. Lucky, with a little bit of magic we can fix that pretty quickly. All we need to do is to download NuGet package prepared by Microsoft called dotnet-watch. In your project.json file add this line to the tools section:


"Microsoft.DotNet.Watcher.Tools": {
    "version": "1.0.0-*",
    "imports": "portable-net451+win8"


Now, in your console instead of „dotnet run” command, type „dotnet watch run„. Change your code, save the file and look! It’s working again! But some of you may not be the enthusiast of running your app through the console. That’s fine; you can achieve the same in Visual Studio if it fits you more. To do that, we’ll use kind of new thing in Web App properties called launch profiles. First, you need to click the „New…” button and name your new profile. Next set the fields like those below:




All you need to do is to save you properties (Ctrl+S) and hit Ctrl+F5. Should work like a charm 🙂


Well, I know that this post was short and not so exciting, but I hope that it’ll help some of you in your work. Currently, I’m on vacation, so that’s why I didn’t publish any longer article for last couple days (hope that you’ll forgive me). Next week, I’ll post the 5th part of our CQRS/ES journey, so if you don’t want to miss that I encourage you to follow me on Twitter or leave a like on Facebook.

You may also like...