dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.03k forks source link

Adding Blazor WebAssembly project reference breaks Hot Reloading for Razor pages #48132

Closed jsheely closed 1 year ago

jsheely commented 1 year ago

Is there an existing issue for this?

Describe the bug

Simply adding a reference from a Razor pages project to a blazor wasm project will break razor pages ability to hot reload the page.

It appears that the Microsoft.NET.Sdk.BlazorWebAssembly project reference is doing something that hijacks the hot reloading

Two notable differences

Before

dotnet watch ⌚ File changed: ./Pages/Index.cshtml.
dotnet watch 🔥 Hot reload of changes succeeded.

After

dotnet watch ⌚ File changed: ./Pages/Index.cshtml.
dotnet watch ⌚ No hot reload changes to apply.

I've created a demo repo. Simply add the un-comment the project reference in the RazorPages1.csproj for the wasm.csproj and change something in the Razor Index.cshtml before and after the reference change

Using dotnet watch and I also tried dotnet watch --project . because I saw that somewhere during debugging

Expected Behavior

I expect that changing the Razor Index.cshtml would hot reload the page just as it did before the web assembly project reference was added.

Steps To Reproduce

Exceptions (if any)

No exceptions

.NET Version

8.0.100-preview.3.23178.7

Anything else?

I've tried this with .net 7 with the same result.

The goal of this is to create a template that has support for Server side static rendering with "Blazor Pockets" of interactivity for either the Blazor Server or Blazor Wasm in any pocket chosen. Both environments supporting hot reloading.

mkArtakMSFT commented 1 year ago

@tmat can you please investigate this? Thanks!

ghost commented 1 year ago

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

jsheely commented 1 year ago

While I still think this may be important to have this option for folks migrating from Razor to Blazor.

I believe the roadmap plan that @danroth27 has illustrated in the Blazor Community Standup .net 8 updates solves my end goals.

I just want to mix server and client components using the same programming model

tmat commented 1 year ago

@jsheely What do you mean by Hot Reload "not working" in the last step?

I tried to repro updating the project to include the project reference while dotnet watch was running and it requested app restart:

dotnet watch ⌚ File changed: .\RazorPages1.csproj.
  ❔ Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?
  ❔ y

After restarting changes I made to Index.cshtml were applied correctly.

Do you mean that Hot Reload shouldn't restart the app when project changes?

ghost commented 1 year ago

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost commented 1 year ago

Hi @jsheely. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.