AddRazorSupportForMvc in RCL stops runtime compilation but without it no partial views are published on Release
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When the setting AddRazorSupportForMvc is added to an RCL like below it stops the runtime compilation from working. If it is removed then no partial views are published on Release.
This is my RCL:
```csproj
net6.0
True
```
This is how I add runtime compilation in the Startup file of the project that references the RCL:
```csharp
if (HostingEnvironment.IsDevelopment())
{
services
.AddRazorPages()
.AddRazorRuntimeCompilation(options =>
{
var libPath = Path.GetFullPath(Path.Combine(HostingEnvironment.ContentRootPath, "..", "Test.ReportsLibrary"));
options.FileProviders.Add(new PhysicalFileProvider(libPath));
});
}
```
This is how my launchSettings.json looks like:
```json
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
}
},
```
### Expected Behavior
I would have expected either adding the AddRazorSupportForMvc setting not to break the runtime compilation OR if the setting was not available my RCL partial views to get published when I do a release.
### Steps To Reproduce
https://github.com/flatproject/AddRazorSupportForMvc
Enable the AddRazorSupportForMvc setting in the RCL and try to edit the Index1.cshtml page in the RCL and refresh to see your change. It will not work.
Disable the AddRazorSupportForMvc setting in the RCL and do a production release. The partial view is not published.
### Exceptions (if any)
_No response_
### .NET Version
6.0.301
### Anything else?
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.2.5
`C:\WINDOWS\system32>dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.301
Commit: 43f9b18481
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.301\
Host (useful for support):
Version: 6.0.6
Commit: 7cca709db2
.NET SDKs installed:
6.0.301 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]`
Contributor guide
Assessment
This issue has not been assessed yet.