This feature was working by default in ASP.NET Core 2.1 but not with the currently latest 2.2.
I've just created two basic ASP.NET Core API projects in Visual Studio 2017 (Community Edition), one with the 2.1 and other with 2.2 template. Then I run both projects with Ctrl + F5 (eg. without debugging). When I go to the /api/values url for each of them I get the default JSON. So far so good.
Now when I change ValuesController.cs in 2.1 project and hit refresh in the browser I see that it takes some time to load because web server detected changes and is rebuilding the project, and then I get the new JSON values. However, when I repeat this same process for 2.2 and hit refresh in the browser I get old values without delay (eg. no project building took place).
So how do I enable this feature in 2.2?
The solution I found is to remove or comment out <AspNetCoreHostingModel>
XML node in project's .csproj
file. So it looks like this:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<!--<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>-->
</PropertyGroup>
Now if you run ASP.NET Core application with Ctrl + F5 (without debugger) it will detect changes in .cs files and recompile at runtime as you make request that depend on new code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With