Closed idseefeld closed 2 years ago
I think it would be best to use our templates to set up a project, open the csproj in VS and when saving it put the solution file somewhere (it will ask you where to put it). Like in v8, we advise you not to use the default MVC template, in v9, we advise you to use the Umbraco template. We are aware that the template doesn't get installed in VS2022 Preview for now so we recommend setting your solutions up in VS2019 stable :)
As it turns out, with your setup in your csproj
you have:
<PropertyGroup>
<RazorCompileOnBuild>true</RazorCompileOnBuild>
</PropertyGroup>
Whereas the default if you use the .NET template would be:
<PropertyGroup>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>
There's no need to compile razor, which is probably why there's too much being compiled.
However, correcting this has led to another error on rebuild:
Severity Code Description Project File Line Suppression State
Error MSB3030 Could not copy the file "D:\Temp\Umbraco9ModelsBuilderSample-main\Umbraco9ModelsBuilderSample.Web\umbraco\config\appsettings-schema.json" because it was not found. Umbraco9ModelsBuilderSample.Web C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 4964
Mostly, I would ask why the need to rebuild at all, a rebuild is hardly ever necessary. I know a lot of people are used to doing it for unknown reasons but a regular build is enough 99,999999% of the time. That is a scientific number, yes! 😉
Anyway, a build after a rebuild with the appsettings-schema.json
error works just fine. I would recommend sticking to not use rebuild for now and it would be great to investigate why the appsettings-schema.json
is there.
I'm sure it SHOULD be possible to compile razor files as well and it would be great to investigate how to fix the original error reported as well.
Hi @idseefeld,
We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.
For more information about issues and states, have a look at this blog post
Thanks muchly, from your friendly Umbraco GitHub bot :-)
@nul800sebastiaan interestingly the following solved the issue:
<PropertyGroup>
<RazorCompileOnBuild>true</RazorCompileOnBuild>
<RazorCompileOnPublish>true</RazorCompileOnPublish>
</PropertyGroup>
Uups, actually I should have known about the extra line, as I have reported the publish issue.
Razor build in this case might be okay(?), because my configuration for ModelsBuilder extracts the models into a folder of the .Core project (see appSettings.Development.json):
"Umbraco": {
"CMS": {
"ModelsBuilder": {
"ModelsDirectory": "~/../Umbraco9ModelsBuilderSample.Core/UmbracoModels",
"AcceptUnsafeModelsDirectory": true,
"ModelsMode": "SourceCodeManual"
},
My understanding here is, that this is the best way to avoid circular dependencies. Whatsoever, setting the value to true fixes your issue 😁
Btw. I did not use VS2022 to create the solution. I have just opened it later on and tried out building times, which probably was the reason for finding the issue😜 (I know you have written about the Rebuild topic in 24days or so and I agree although I am not aware of the exact difference between the combination of Clear & Build vs Rebuild🤔) Ähm, and shame on me, I admit that frustration and confusion😵 about a broken build lets me try out these kind of helpless actions.🤫🤭
Nevertheless there must be differences in the behaviour of VS2019 vs VS2022 as my example clearly shows. So from my point of view their comment is wrong. 🙄
Finally I close the issue!
@nul800sebastiaan Sorry, I have reopen this again. I am not sure what happend:
Maybe I have used VS2019 and not VS2022 as the Rebuild seems to work🤪
Would be nice if someone could verify with the previous VS2022...
Or we take your advice for now and do not use Rebuild. In the end VS2022 is still in preview🙄
Just found another hint: If you execute Clean Solution before Rebuild Solution you get no error. I see a lot of files get deleted during Clean Solution. These are not only DLLs (as usual?). Has this to do with the new template approach? Okay, I need to read the docs...
Just found another hint: If you execute Clean Solution before Rebuild Solution you get no error. I see a lot of files get deleted during Clean Solution. These are not only DLLs (as usual?). Has this to do with the new template approach? Okay, I need to read the docs...
We clean up files on clean, and add files (if missing) on build. This all happens in the targets file from the nuget package: https://github.com/umbraco/Umbraco-CMS/blob/v9/dev/build/NuSpecs/build/Umbraco.Cms.StaticAssets.targets
Just to chime into this, I am using the razor compile on build & publish, I've also found odd behaviour at one point if you have one on & not the other, but my models are in a separate compiled destination hence my use of it. Not to mention if this is not enabled, then the site can break when deployed due to Umbraco generating its own files & then there being ambiguous references etc.
Also I find that Umbraco is quite a lot faster when the razor files are compiled into the solution, presumably because they are not being re-compiled when the site starts up anymore etc. Just watch out that you have both set to true, otherwise Umbraco itself gets upset and starts breaking at times as well (when using dotnet publish) which I now have a setup whereby I am deploying a whole Umbraco site just by using dotnet publish on & pushing it to a build server which then deploys the output zip to a folder & it works without a hitch now.
Just looking at the source this looks like Clean/Rebuild would wipe out ALL assets in the umbraco folders. E.g. if I have a custom language file in umbraco\config\lang it would also be removed. Is this intentional?
@bachratyg Yes, the files in ~\umbraco\config\lang
will be overwritten on build so don't change them.
You can put custom language files in ~\config\lang\lang.user.xml
instead. Any keys you put in there will also override the default language keys that come with Umbraco.
And example of overriding an existing language can be found here: https://github.com/umbraco/Umbraco-CMS/issues/11345#issuecomment-939976835
And if you have your own language file. let's say for Ukranian, I believe you would start a new file ~\config\lang\ua.user.xml
and that should work.
I just realized that this specific issue has been fixed in https://github.com/umbraco/Umbraco-CMS/pull/11216 for the 9.0.1 release tomorrow, I'll close this one as fixed!
Which exact Umbraco version are you using? For example: 8.13.1 - don't just write v8
v9-RC
Bug summary
What I did
I am testing Visual Studio 2022 Community Preview edition and have a solution with a .Net 5 MVC Website project depending on a class library project. Command combination of Clean and Build solution works. Using just Rebuild fails with:
You may clone repo https://github.com/idseefeld/Umbraco9ModelsBuilderSample to reproduce the issue. The issue might be related to this solutions specifics, but in Visual Studio 2019 Community edition Rebuild works.
Microsoft response
This issue seems to be caused by Umbraco (particularly the Umbraco.StaticAssets package) are built and not Visual Studio or the .NET Core SDK. We recommend filing an issue at their project site: https://github.com/umbraco/Umbraco-CMS. For more information, see also our issue reporting guidelines.
🙄Any idea?
Kind regards, Dirk
Specifics
Please find Microsoft issue report here: https://developercommunity.visualstudio.com/t/error-on-solution-rebuild-in-visual-studio-2022/1477291
Steps to reproduce
Expected result / actual result
In Visual Studio 2019 Community edition Rebuild Solution works.