You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.1.2
Bug summary
Umbraco .cshtml files (<projectDir>\umbraco\**\*.cshtml, e.g. umbraco\UmbracoInstall\Index.cshtml) are not compiled by the built-in Razor generator when building the project after a dotnet clean, or if the files were simply not there before you start the build. The latter happens all the time on a build server. Normally, all .cshtml files are compiled into <project>.Views.dll and you do not need to put any .cshtml files on your webserver anymore which is great.
The target responsible for gathering the input .cshtml files for the Razor generation is "ResolveRazorGenerateInputs". As you can see it simply includes any <Content> items that have a .cshtml extension.
The Umbraco .cshtml files are copied before build using a target defined in Umbraco.Cms.StaticAssets.targets, but apparently not picked up by the Razor generation target on time.
A possible fix
The simplest fix is to manually include the Umbraco .cshtml files before the "ResolveRazorGenerateInputs" target runs.
This way we do not have to change anything about the existing "CopyUmbracoAssets" target so the impact should be minimal.
I will link a PR to this issue that includes this target in Umbraco.Cms.StaticAssets.targets so you can easily merge it if you agree with this solution. Of course if you prefer to solve it in another way then that's totally fine!
Add this to the bottom of your .csproj (before </Project>):
The quickest way to show this is by opening a newly installed Umbraco project because this will run the umbraco\UmbracoInstall\Index.cshtml file which is one of the files not being compiled after a clean build.
We should be able to remove that .cshtml file just fine but when we do after a clean build we see an exception:
> dotnet new umbraco -n Razor > cd Razor
open Razor.csproj in some editor, set RazorCompileOn{Build,Publish} to true.
Do not worry about ModelsBuilder comment that HQ put there we will show the bug before any models are generated.
Observe it works fine now, the cshtml files are compiled into Razor.Views.dll and the installer loads fine without UmbracoInstall\Index.cshtml on disk.
If you apply the fix mentioned in the summary you can run a clean + publish again and it will still work.
Expected result / actual result
No response
The text was updated successfully, but these errors were encountered:
Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9
9.1.2
Bug summary
Umbraco .cshtml files (
<projectDir>\umbraco\**\*.cshtml
, e.g. umbraco\UmbracoInstall\Index.cshtml) are not compiled by the built-in Razor generator when building the project after adotnet clean
, or if the files were simply not there before you start the build. The latter happens all the time on a build server. Normally, all .cshtml files are compiled into<project>.Views.dll
and you do not need to put any .cshtml files on your webserver anymore which is great.The target responsible for gathering the input .cshtml files for the Razor generation is
"ResolveRazorGenerateInputs". As you can see it simply includes any
<Content>
items that have a .cshtml extension.The Umbraco .cshtml files are copied before build using a target defined in Umbraco.Cms.StaticAssets.targets, but apparently not picked up by the Razor generation target on time.
A possible fix
The simplest fix is to manually include the Umbraco .cshtml files before the "ResolveRazorGenerateInputs" target runs.
This way we do not have to change anything about the existing "CopyUmbracoAssets" target so the impact should be minimal.
I will link a PR to this issue that includes this target in
Umbraco.Cms.StaticAssets.targets
so you can easily merge it if you agree with this solution. Of course if you prefer to solve it in another way then that's totally fine!</Project>
):Specifics
No response
Steps to reproduce
The quickest way to show this is by opening a newly installed Umbraco project because this will run the umbraco\UmbracoInstall\Index.cshtml file which is one of the files not being compiled after a clean build.
We should be able to remove that .cshtml file just fine but when we do after a clean build we see an exception:
> dotnet new umbraco -n Razor
> cd Razor
RazorCompileOn{Build,Publish}
to true.> dotnet clean && dotnet publish -o pub
> cd pub
> del umbraco\UmbracoInstall\Index.cshtml
> set ASPNETCORE_ENVIRONMENT=Development
> Razor.exe
This runs the site
goto https://localhost:5001 (or http://localhost:5000 for HTTP)
Observe exception:
"InvalidOperationException: The view '/umbraco\UmbracoInstall\Index.cshtml' was not found."
To see it will work if the .cshtml files are already on disk, repeat this process again but without a
dotnet clean
you will notice it simply works:> cd ..
> rmdir /s /q pub && dotnet publish -o pub && cd pub && del umbraco\UmbracoInstall\Index.cshtml && set ASPNETCORE_ENVIRONMENT=Development&&Razor
If you apply the fix mentioned in the summary you can run a clean + publish again and it will still work.
Expected result / actual result
No response
The text was updated successfully, but these errors were encountered: