question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET 6 hot reload support.

See original GitHub issue

Yesterday I hacked together rudimental hot reload support that is coming in .NET 6 for asp.net projects. For me this is useful because with Service Fabric and angular I’m having inner development loop times of several minutes, and it’s untenable. I’m looking at tye with Dapr with Blazor, just for this reason. This is just a trial to see whether it would work, but to make it into a decent PR, a bit of discussion might be necessary. Also, I’m not familiar with the inner workings of tye, which is why this may seem rather hacky. I’m very open to suggestions for improvement.

The changes are here:

https://github.com/dotnet/tye/compare/main...jspuij:net6hotreload

The way I did it was to disable the internal file watching of tye and run dotnet watch run instead of the executable directly. There are some advantages and disadvantages to this approach:

Advantages:

  • Hot reload seems to be working and certainly improves inner loop time.
  • RCL static web asset resolution works, which doesn’t work when you start the executable directly. (this is another issue with the current tye).

Disadvantages:

  • Tye file watching is replaced with dotnet file watching. With hot reload the executable will keep running. With hot reload disabled, or in case of a failure, tye routines that would normally run when a process is restarted, won’t be run because dotnet watch run will keep running, even though the child process might be restarted. No idea whether this is important, but it’s a consequence.
  • Hot reload does not work with the --no-build switch, so tye will do another build of the asp.net project. This might be something that can be debated with the aspnetcore team. @SteveSandersonMS might have some tips on the hot reload mechanism.
  • I think there might be very wonky results if two microservices have hot reload enabled and have a reference to a shared library. I’m not sure that the shared library is even monitored for changes, but if it is, this is a scenario that should be tested and looked at.
  • Nothing tried or tested with projects run inside a container instead of directly on the host.

This might not be the route to take at all, but even then this issue can serve as a starting point for implementing hot reload support in Tye.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:27
  • Comments:8

github_iconTop GitHub Comments

3reactions
NicolaiOksencommented, Mar 17, 2022

Any words on this? It would greatly improve the dev flow if hot reload was supported.

2reactions
MarkusRodlercommented, Nov 17, 2021

I think this is not necessary as @jspuij demonstrated it in his commit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET Hot Reload support for ASP.NET Core
Hot Reload is supported for all ASP.NET Core 6.0 and later projects. Generally, updated code is rerun to take effect with the following ......
Read more >
Hot Reload In C# .NET 6 / Visual Studio 2022
Notably that if you edit your application startup (Or other run-once type code), your application will hot reload, it doesn't re-run any code...
Read more >
Hot Reload not working in Visual Studio 2022 .Net 6 Razor ...
The .NET 6 projects hot reload doesn't seem to work. Hot Reload is enabled, but our Front End is never updated. Refreshing the...
Read more >
Hot Reload in .NET 6- An Overview
Hot reload is one of the most impressive features in .NET 6 and was introduced in the .NET 6 Preview 3 version. It...
Read more >
.NET Hot Reload Adds Support for Modifying Generics - InfoQ
With Hot Reload it's possible to edit your .NET application's code while the application is running and apply those changes without restarting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found