-
Notifications
You must be signed in to change notification settings - Fork 646
Conversation
This is not ready to go in yet as there are problems to be debugged:
These problems occur much more frequently if you're using Firefox (presumably because it's so much faster to do a reload on a WebAssembly app page). |
31d83d5
to
41b4f46
Compare
Update This is now rebased on dev as of March 16. I haven't tracked down why the E2E test fails in AppVeyor when it works reliably both locally on Windows and on Mac/Linux on Travis (and it used to work on AppVeyor before the move to the new build mechanism). Currently this works really well for standalone projects when you're hosting directly on Kestrel, or for hosted projects when you do a single-project build (e.g., shift+F6) for the client project. Problems:
|
04f7aba
to
cdc1f16
Compare
If you are building inside VS, then it's possible you're building an arbitrary collection | ||
of projects of which this is just one, and it's important to wait until all projects in | ||
the build are completed before reloading, so the notification is instead triggered by the | ||
VS extension that can see when a complete build process is finished. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the work that billhie is going for us? Or will we need to add something ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bill is doing some work to avoid the unwanted IISExpress recycles - it's related to this work item, but not to this comment.
We will have to do some work in our VS extension ourselves to detect when a build completes and write the signal file. I was expecting to do that, though I may have to ask for your advice on it since I have no experience of writing any VS extension code.
// you probably want to wait until they've all been written before reloading. | ||
// Pausing by 500 milliseconds is a crude effort - we might need a different | ||
// mechanism (e.g., waiting until writes have stopped by 500ms). | ||
private const int WebRootUpdateDelayMilliseconds = 500; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also consider using files as a notification. Write a file with a particular name as the first change and then delete it when the build is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's (almost) exactly what we do :) https://github.com/aspnet/Blazor/pull/193/files#diff-017c9b5955fe407916ebe35f7ee07012R63
Only difference is we both write and delete it at once, when the build is complete. We don't need to notify the client that a build is beginning (at least we don't have any need for that yet).
@rynowak I'll merge this as-is unless you have any concerns. |
This reverts commit 5b45014.
…'re changing how the server recycles to avoid this
…to be done from the VS extension instead.
…on environment, regardless of client app config
5f3a5dd
to
f18e396
Compare
Now merged into |
I'm confused; does this mean auto-reloading is working? I am unable to find another issue that describes this feature as either done or not ready yet. |
@szalapski Not quite. Currently we support auto-rebuild, where the Blazor app will rebuild automatically in VS when you make changes, but you still have to refresh the browser. Support for full auto reload is tracked by dotnet/aspnetcore#5456. |
Thanks for the update. So this merge is to get auto-rebuild without using "dotnet watch run"? Is the way to configure this documented somewhere? |
This update enabled auto build in VS. You still use |
If you are working with standalone Blazor, I've found you don't even need dotnet watch, you just save the code and reload the browser - that triggers a rebuild. |
Working from the command line, I find that edits to a .cshtml do not trigger a rebuild, and so I think I do indeed have to use |
Is there a guide for how to get the auto-build set up? I just created a new Blazor server project in Visual Studio and I have to restart from Visual Studio whenever I make changes. I would love for it to be as easy as refreshing the browser. |
@danroth27 - Sorry to bump a super old thread again. Still haven't seen any documentation on how to enable the 'Auto Build' feature in Visual Studio 2019. Any pointers? |
@Tiberriver256 To turn on auto rebuild and refresh in VS, use this option: It's admittedly a bit hard to find unless you know where to look. |
I enabled auto build and refresh after save as you showed and also set the automated Kestrel restart to true (cause I'm not using the IIS): Now I change My VS Version was 16.8.1, I updated to 16.8.5 but the only difference was that after the first save VS asked me where to store the file (like with save as). After that it behaves the same. When I set breakpoints, then change and save the code, VS grays them out with a notice that they won't be reached. I tried running But I don't have a debugger there, for that reason I'd prefer to use Visual Studio. I can't get it work there, even not when using the IIS Express. Installed .NET version dotnet --version
5.0.103 |
@DMW007 When running in VS are you running with the debugger attached? Auto restart and refresh are only supported when running without the debugger (Ctrl+F5). |
No description provided.