leekelleher / umbraco-contentment

Contentment for Umbraco - a state of happiness and satisfaction
https://marketplace.umbraco.com/package/umbraco.community.contentment
Mozilla Public License 2.0
157 stars 72 forks source link

Build error on compiling unless I clean #125

Closed Matthew-Wise closed 3 years ago

Matthew-Wise commented 3 years ago

Which Contentment version are you using?

3.0.0-alpha003

Which Umbraco version are you using? For example: 8.14.1 - don't just write v8

9.0.0-rc001

Bug summary

I am getting the following two errors:

CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Umbraco.Web' (are you missing an assembly reference?) \obj\Debug\net5.0\Razor\App_Plugins\Contentment\render\ContentBlockPreview.cshtml.g.cs 16 Active

CS0115 'App_Plugins_Contentment_render_ContentBlockPreview.ExecuteAsync()': no suitable method found to override \obj\Debug\net5.0\Razor\App_Plugins\Contentment\render\ContentBlockPreview.cshtml.g.cs

Steps to reproduce

Setup models builder to use anything other than InMemoryAuto, I used SourceCodeAuto then in the csproj file follow the comment from Umbraco

 <!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
    <PropertyGroup>
        <RazorCompileOnBuild>false</RazorCompileOnBuild>
        <RazorCompileOnPublish>false</RazorCompileOnPublish>
    </PropertyGroup>

Setting these to true, causes the errors above.

Expected result / actual result

The build does not error unless I have done something stupid like missing a ;

Do you have Umbraco ModelsBuilder enabled?

What browsers are you seeing the problem on?

No response

leekelleher commented 3 years ago

Hi @Matthew-Wise, thanks for raising this.

The first error (CS0234) is because I missed updating a namespace.

https://github.com/leekelleher/umbraco-contentment/blob/3.0.0-alpha003/src/Umbraco.Community.Contentment/DataEditors/ContentBlocks/ContentBlockPreview.cshtml#L5

It should be Umbraco.Cms.Web.Common.Views.ContentBlockPreviewView instead of Umbraco.Web.Mvc.ContentBlockPreviewView. Whether that causes the CS0115 error too, I'm not sure.

Strange thing is that I've tested out the Content Blocks preview feature and it doesn't error in the backoffice. 🤔

I'm not sure about the Razor files compiling in the Contentment csproj itself, I haven't added anything to enable/disable that.


I'll fix up the Razor namespace reference during this week. (I'm currently holding the fort at work while others are on holiday this week).

Matthew-Wise commented 3 years ago

I'm not sure about the Razor files compiling in the Contentment csproj itself, I haven't added anything to enable/disable that.

The csproj change is in my Umbraco project.

I assume it will still all work after the clear and rebuild, I haven't reached a point where I am using Contentment but know Ill need it.

leekelleher commented 3 years ago

Fixed in Contentment v3.0.0-alpha004.