-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot reload does not work for Razor page in OC 1.8.3. #15946
Comments
Did you try a "Hot Reload" option from VS? |
@hishamco thank you so much for prompt reply. |
This issue is related to this discussion => #15321. |
I know :) what I'm asking is to try, we need to make sure is happen for both options or only related to |
It has never really worked well with VS Code as far as I remember but the VS Code launcher option should be there. If you need Hot Reload I believe you should use Visual Studio as it is better supported. |
Can you checkout this issue and see if it helps |
@aaronamm
that option is disabled by default ,Because opening it requires more resources, such as memory and compilation time. You can add the following configuration lines to your local file <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
</ItemGroup>
|
@MikeAlhayek ,It works fine on my end with no problems, I think this question should be converted to a discussion |
@hyzx86 I think all you need is to add
I have not had time to test it and see if this is a problem of not. |
This comment was marked as outdated.
This comment was marked as outdated.
I tested it and it does work, no problem |
@hyzx86 I just tested it real quick to provide you feedback and I am getting a runtime error
All of the views seems to have similar error
|
Which branch is this? 1.8.3 ? |
main |
There should be no problem with the main branch. I was still using it a few days ago. |
I tried it today, and the main branch code is fine, but Visual Studio may have some caches that need to be cleared when switching branches, or else strange problems may occur. I even found that I was able to hot update the cs file when I tweaked it. But the second time I made the changes Visual Studio hit a fatal error and the debugger crashed 🤣 |
I did that too but that does not work. Remember that I am doing this is a project that references the OC packages not the OC project itself. By the way, executing |
You can use |
@hishamco the command |
@MikeAlhayek , If you need to debug OC source code during development, you can try this module. |
You can step through code or use a debugger from within VS Code or VS, is there any special about the |
I have a framework based on OC, the business code is in another project, then the framework can be separated from the business, before the module I use the submodule but the submodule needs to be modified sln file In turn, I can create a local branch of OC and add a reference to this module, and I can debug my other OC modules in OC source code |
I have the same issue in VS 2022 + OC 1.8.2 + .NET 8.0 OC 1.7.2 works well. |
My project is organized according to OC's dependency package management. But just now when I modify the After ignoring this window, refresh the page and still can apply the changes |
More context in this duplicate: #16504. |
I think I may have located the source of this issue. It was introduced by PR #14348.
Could we register this provider only in the production environment? Something like this: // Support razor runtime compilation only if in dev mode and if the 'refs' folder exists.
var refsFolderExists = Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "refs"));
if (_hostingEnvironment.IsDevelopment())
{
if (refsFolderExists)
{
builder.AddRazorRuntimeCompilation();
}
}
else
{
// Share across tenants a static compiler even if there is no runtime compilation
// because the compiler still uses its internal cache to retrieve compiled items.
services.AddSingleton<IViewCompilerProvider, SharedViewCompilerProvider>();
} I'm not sure if the changes are correct. If they are, would it be possible for me to submit my first pull request? |
Hmm, interesting, and if this fixes the issue then certainly, please open a PR. But I'm still wondering why hot reload works for me with the same code. @DavidStania could you please test the above code changes? |
I can confirm that this fixes the hot reload issue, which I have as well. We would be happy if you want to submit your first PR. |
It doesn't matter whether |
Genius! It works for me! |
Just to note, this issue is about hot reload. Runtime compilation is a different beast 😊 |
Describe the bug
Hot reload stop working Razor page in OC 1.8.3.
It does work perfectly if we rollback to OC 1.7.2.
To Reproduce
Steps to reproduce the behavior:
dotnet watch run
Expected behavior
Development environment
The text was updated successfully, but these errors were encountered: