Blazor debug and live reload

Mark Hayford
2 min readApr 25, 2020

--

edit DEC 2021 I have to believe this is out of date by now….

Your smart you probably understand what this is doing so do it

or down the page for more explanation

Open powershell window

dotnet watch run

In visual Studio

Menu --> Debug--> Attach to Process --> (find your process, Mine was dotnet.exe)

Another powershell window

browser-sync start 
>> — proxy http://localhost:5000/ `
>> — files ‘**/*.cshtml, **/*.css, **/*.js, **/*.htm*’ — reload-delay 15

You may need to run the re-attach debug every time — for some reason I did not and I don’t care to figure out why cause it’ll break something.

alt shift p

More Explanation

Stealing from these articles so

go there and thank those authors.

This is pretty Quick and simple I wanted to live reload serverside blazor and debug the application at the same time. These two articles got me there.

Dotnet watch and Browser sync. And then attaching the debug process to the dotnet watch command.

It was pretty easy to set up.

Open powershell and run this

dotnet watch run

Attach the debugger — debug — attach to process. mine was called dotnet.exe run browser sync I added the delay

browser-sync start 
>> — proxy http://localhost:5000/ `
>> — files ‘**/*.cshtml, **/*.css, **/*.js, **/*.htm*’ — reload-delay 15

a delay to reload of 15 seconds was way better than clicking a bunch of windows and things popping up in different browsers or whatever was happening before that I hated.

— reload-delay 15

You could probably script all these together and if you do let us know and we’ll point people your way.

--

--

Mark Hayford
Mark Hayford

Written by Mark Hayford

A fuzzy life. Fuzzy computer problems. fuzzy Dog friends. fuzzy thoughts.

No responses yet