-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Razor runtime view compilation via environment variable not working in .NET 6 #38465
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
Comments
cc @halter73 (might be a hosting problem) |
@AndrewTriesToCode thanks for contacting us. @pranavkm do you have any thoughts? |
Thanks for contacting us. We're moving this issue to the |
This was introduced as a result of my attempt to refactor the way action descriptors are registered for Razor. Runtime compilation requires adding a matcher policy and a different ADP, which is currently contingent on the default one being already registered: https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/RazorRuntimeCompilationMvcCoreBuilderExtensions.cs#L88-L99. This unfortunately does not happen with the env variable since the hosting startup runs before That said, for 6.0, we intentionally removed the option of conditionally enabling runtime compilation from our project templates because we believe hot reload is a better dev time alternative. Particularly for .cshtml files, you get really high fidelity for the kinds of edits that are supported, so there generally shouldn't be a reason to require this feature. |
Thanks for the details. My experience on Mac has been that hot reload only works on non-debug runs, causes an error, and is disabled for the rest of the session. It might be due to the fact that I use Rider so I’ll try it in VS code. |
@pranavkm Should this go on the backlog then? I'm putting it there but please feel free to move it if you disagree. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
In our Single Page App scenarios/setups, this is a crucial feature and hot reload does not replace it properly. No matter what I tried, it just doesn't work in .Net 6. In my opinion, the extension method "AddRazorRuntimeCompilation" should either be fixed or completly removed. |
I have a project that I have yet to update to .Net 6 because of this problem. Hot reload isn't working either. Is it because I am debugging on IIS with VS that hot reload isn't working properly? If that is the case then I would like either for Hot Reload to work with when debugging with IIS or fix |
As part of refactoring how Razor Pages are loaded, the ability to use runtime compilation via the hosting startup / env variable was broken. The refactoring assumed AddRuntimeCompilation was always invoked after a call to AddRazorPages / AddControllersWithViews etc which is not the case for registration via the HostingStartup. This PR address this defect. Fixes dotnet#38465
…39381) As part of refactoring how Razor Pages are loaded, the ability to use runtime compilation via the hosting startup / env variable was broken. The refactoring assumed AddRuntimeCompilation was always invoked after a call to AddRazorPages / AddControllersWithViews etc which is not the case for registration via the HostingStartup. This PR address this defect. Fixes #38465
…otnet#39381) As part of refactoring how Razor Pages are loaded, the ability to use runtime compilation via the hosting startup / env variable was broken. The refactoring assumed AddRuntimeCompilation was always invoked after a call to AddRazorPages / AddControllersWithViews etc which is not the case for registration via the HostingStartup. This PR address this defect. Fixes dotnet#38465
…otnet#39381) As part of refactoring how Razor Pages are loaded, the ability to use runtime compilation via the hosting startup / env variable was broken. The refactoring assumed AddRuntimeCompilation was always invoked after a call to AddRazorPages / AddControllersWithViews etc which is not the case for registration via the HostingStartup. This PR address this defect. Fixes dotnet#38465
…39381) (#39639) As part of refactoring how Razor Pages are loaded, the ability to use runtime compilation via the hosting startup / env variable was broken. The refactoring assumed AddRuntimeCompilation was always invoked after a call to AddRazorPages / AddControllersWithViews etc which is not the case for registration via the HostingStartup. This PR address this defect. Fixes #38465
Runtime view compilation appears to not be working in .NET 6 Razor Pages projects when using the environment variable to specify this behavior as described here:
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-6.0&tabs=visual-studio#conditionally-enable-runtime-compilation-in-an-existing-project
If I manually add
AddRazorRuntimeCompilation()
in ConfigureServices it does work though.I'm including v6.0.0 of the assembly package:
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.0" />
And my launch profile has the following section:
Worked as expected in .NET 5 on the same project.
The text was updated successfully, but these errors were encountered: