In this segment, we will talk about Dot Net Watch Tool. Dotnet watch tool is a file watcher for dotnet that restarts the application when changes in the source code are detected. This is actually similar to nodemon, if you are familiar to node js, then this must be familiar to you. If you are using IIS Express then, it actually does this restart for you already. This piece is really helpful if you are running the app in console.
For one genuine reason, you can choose this because you will see logs flashing in the console. Dot Net Watch Tool comes with Visual Studio 2015 Update 3 by default. Below is the screen shot for the same.
Now, when I select the same and run the same, then it will produce the same expected output plus one console window which will show the complete log file as shown below.
Now, since I am running this in DotNet Watch Tool, hence any changes which I do in view let’s say below change, upon saving it will automatically reflect.
Behavior is same when I run the same from IIS-Express, but it actually shines when, I am running the same from cmd line tool like shown below. Therefore, from cmd line, when I typed dotnet watch first time, it gave error like shown below.
Therefore, for cmd line stuff, we need to exclusively install the library “Microsoft.DotNet.Watcher.Tools”: “1.0.0-preview2-final*” and manually do package restore as in this case it automatically not triggers.
Once, the restore is completed, you can verify the same in project.lock.json file as shown below.
With the above change in place, when I go ahead and run the same again, it will show the below message.
Now, in order to run the app in watch mode, I will type dotnet watch run. This triggered the app in watch mode as shown below.
Here, when I navigate to localhost:5000, it will produce the below expected output.
Now, if I change any thing in files like HTML, CSS or JS file and then refresh the page, it will quickly come into effect. Therefore, let’s say if you are building the app in visual studio code, then this tool is very useful.
1,908 total views, 1 views today