Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ASP.NET vNext, why is code not recompiled on the fly?

I am running the HelloMvc sample application from the command line using k web. I have tried to run it using the different environments available to me using kvm use -runtime. When I change the controller and hit F5 (or Ctrl+F5) in the browser, the code is not recompiled automatically and the page does not change. What am I doing wrong?

    Active Version      Runtime Architecture                         
------ -------      ------- ------------ 
       1.0.0-alpha3 svr50   x86          
       1.0.0-alpha3 svrc50  x86          
       1.0.0-alpha4 CLR     x86          
  *    1.0.0-alpha4 CoreCLR x86
like image 841
martijn_himself Avatar asked Oct 15 '14 10:10

martijn_himself


1 Answers

Running dnx web from your command line only starts your host. To get the automatic recompilation goodness something needs to watch the files for changes and restart your host if any changes are detected. To accomplish this use the --watch flag and run your web command like this:

dnx --watch web

Currently this just shuts down your host when a change is detected, so you need something that restarts it once that happens. IISExpress does this for you if you run your project from Visual Studio 14.

Your best bet for this workflow outside of Visual Studio is through a JavaScript build tool or npm scripts. I would recommend you to look into this gulp-aspnet-k plugin (note this plugin only works on windows currently) if you want continuous recompilation on file changes while working outside of VS14. Seems to be the best way to accomplish that without IISExpress that I have found. This plugin is/was windows specific, but looking at the code should get you started. :)

Glenn F. Henriksen has written a wrapper for nodemon that is very nice, called kmon. Try that out as well. The kmon GitHub repository has all the instructions you need

like image 109
AndersNS Avatar answered Nov 11 '22 14:11

AndersNS