.NET 6 Hot Reload support

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 anos atrás
Hi,

Does the project support Hot Reload introduced in .NET 6? https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/

I'm referring especially to it in the context of loading changes made in plugins. Currently you need to rebuild the plugin, then restart and rebuild the main Nop.Web project.

Is there any way to leverage Hot Reload for this and not have to keep rebuilding the projects?

Thanks,
Szilard
2 anos atrás
I assume you are talking about with Visual Studio. There have been a lot of issues with Hot Reload and a number of preview versions of Visual Studio being released. I have been reporting the issues on their forum as it has been virtually useable.

There is another one today Version 17.2.0 Preview 3.0 which I hope will fix it - I am only just getting to  try it out now - see what happens.
2 anos atrás
szilardd wrote:
... rebuild the main Nop.Web project. ...


Hot Reload would be nice.  In the meantime, you can speed up the rebuild/restart a little by ...
   right-click the solution, Properties, Configuration Properties, Configuration:  uncheck Build for all except the one plugin.
2 anos atrás
Would hot reload work for plugins?
2 anos atrás
Yes in theory it works for all code (and Plugins once they have been installed)
It just has not been working very well - but they seem to be getting the bugs out slowly
Another Preview - Version 17.2.0 Preview 4.0 just released - I am about to try it out and see
2 anos atrás
Tried using hot reload now with VS 2022 preview on latest version.

Firstly. This took forever and VS stopped responding:


After a while i got this one:


And then:
1 ano atrás
New York wrote:
... rebuild the main Nop.Web project. ...

Hot Reload would be nice.  In the meantime, you can speed up the rebuild/restart a little by ...
   right-click the solution, Properties, Configuration Properties, Configuration:  uncheck Build for all except the one plugin.


Wouldnt that just be the same as a normal right click -> build on the plugin itself?
1 ano atrás
Not linked directly to Hot Reload, but I've been trying to find a way to speed up the build-run process. This assumes that you make changes only in the code of the Plugin project:

1. Run the `Nop.Web` project from command line as


dotnet watch run --no-build


This means that it will only run the project, without building it every time. It starts in about 5 seconds, which is ok.

2. Update the *.csproj of your Plugin project

Add this line into the `AfterTargets="Build"` section.


<!-- Trigger Nop.Web reload -->
    <Exec Command="powershell  (ls '..\..\..\..\src\Presentation\Nop.Web\Controllers\HomeController.cs').LastWriteTime = Get-Date" />


My project is in a separate folder, not `src\Plugins`, so the relative path might need to be adjusted slightly.

What this does is that after the plugin finishes building, it will trigger a change in the Nop.Web project, which will restart the application and will load in the latest changes from the Plugin. It should look like this:

  
<!-- This target execute after "Build" target -->
  <Target Name="NopTarget" AfterTargets="Build">
    <!-- Delete unnecessary libraries from plugins path -->
    <MSBuild Projects="@(ClearPluginAssemblies)" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
    <!-- Trigger Nop.Web reload -->
    <Exec Command="powershell  (ls '..\..\..\..\src\Presentation\Nop.Web\Controllers\HomeController.cs').LastWriteTime = Get-Date" />
  </Target>


3. Watch & build the Plugin project from the command line:


dotnet watch build /p:BuildProjectReferences=false


This will only trigger a build for the Plugin, and it will ignore other project references like Nop.Web or Nop.Web.Framework

---
If you save any file in the Plugin project, it will rebuild the plugin automatically and will also trigger a restart for Nop.Web.

4. If you want to enter Debug mode, attach the debugger from Visual Studio to the `Nop.Web.exe` process. No need to start a different debug session or rebuild.
1 ano atrás
FYI, I've mentioned this a few times in the past
https://www.nopcommerce.com/en/boards/topic/51890/speed-of-debugging-when-developing-400-plugins#203941
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.