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

[v3.0] Unable to build project #175

Closed AaronSadlerUK closed 3 years ago

AaronSadlerUK commented 3 years ago

Which Contentment version are you using?

3.0.0

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

9.0.1

Bug summary

Unable to build project after upgrading from the beta to 3.0.0 stable

Steps to reproduce

Upgrade from 3.0.0-beta001 to 3.0.0 stable

Expected result / actual result

Expected the project to build, instead I get the following errors:

error CS0246: The type or namespace name 'ContentBlockPreviewView' could not be found (are you missing a using directive or an assembly reference?)
error CS0115: 'App_Plugins_Contentment_render_ContentBlockPreview.ExecuteAsync()': no suitable method found to override

Do you have Umbraco ModelsBuilder enabled?

What browsers are you seeing the problem on?

No response

bjarnef commented 3 years ago

I noticed the same error, but excluding "Contentment" folder in App_Plugins fixed the issue locally. However I am not sure if that will work on Umbraco Cloud as I think it need to be included to be copied from repository to site.

leekelleher commented 3 years ago

Hmm ๐Ÿค” I'd removed the explicit namespace from the @inherits of the Razor view, so to make it work with multi-targeting, for both v8 & v9). Obviously it doesn't, bah! Back to the drawing board... open to suggestions.

bjarnef commented 3 years ago

@leekelleher I haven't tested this, but maybe the approach @mattbrailsford used in Vendr Checkout? https://github.com/vendrhub/vendr-checkout/tree/v2/dev/src/Vendr.Checkout/Web/UI/App_Plugins/VendrCheckout/views

AaronSadlerUK commented 3 years ago

@leekelleher I haven't tested this, but maybe the approach @mattbrailsford used in Vendr Checkout? https://github.com/vendrhub/vendr-checkout/tree/v2/dev/src/Vendr.Checkout/Web/UI/App_Plugins/VendrCheckout/views

I was about to mention Matt ๐Ÿ˜‚

leekelleher commented 3 years ago

Maybe it's a gap in my .NET Core (5) knowledge... is there a csproj setting to make it compile the Razor views? I thought Umbraco's default functionality was to disable that? (Only that I didn't get this error when I tested the package our during development)

AaronSadlerUK commented 3 years ago

I'm not sure how Matt achieved it, I think he mentioned it on Slack

benjaminc commented 3 years ago

@leekelleher there are the RazorCompileOnBuild and RazorCompileOnPublish settings in the csproj file, however the default csproj that comes with Umbraco v9 says to set those to "true" unless you are using Models Builder in InMemoryAuto mode.

mattbrailsford commented 3 years ago

Isnโ€™t the default in the Umbraco template that those are set to false?

https://github.com/umbraco/Umbraco-CMS/blob/v9/contrib/build/templates/UmbracoProject/UmbracoProject.csproj#L45

benjaminc commented 3 years ago

Yes. I believe the default is false, and the comment says to set them to true.

mattbrailsford commented 3 years ago

Oh, I see what you mean. The code comment says to set them to true.

mattbrailsford commented 3 years ago

Seems odd thatโ€™s the case to me though as doesnโ€™t that mean the back office settings section is potentially pretty useless once a site is published?

AaronSadlerUK commented 3 years ago

But if you're using Models Builder that would be correct as the DLLs are compiled... And any setting changes wouldn't be reflected anyway

benjaminc commented 3 years ago

Possibly, but that usually what we want for our production sites (and yes, I realize that isn't the case for everyone, just speaking for myself here). For most of the sites we create, we tell the clients to not touch anything in the Settings section. If there was a way to force read-only mode for that entire section for most people, I'd love it for most of our clients. We've had issues where people try to make changes there, but the changes never make it back to source control and then they lose them the next time we do an automated deploy.

leekelleher commented 3 years ago

Thanks @benjaminc, I'll give the RazorCompileOnBuild setting a try. I must have only tested the package with it set to false, (as @mattbrailsford says, Umbraco's default configuration).

I'm expecting it to be a quick fix. ๐Ÿ‘

leekelleher commented 3 years ago

Update on this one. I added a _ViewImports.cshtml file to the "~/App_Plugins/Contentment/render" directory, with the contents...

@using Umbraco.Cms.Web.Common.Views;

...and the project compiles fine. ๐ŸŽ‰

The reason I omitted the namespace from the Razor view is that the ContentBlockPreviewView class has different namespaces between the v8 and v9 versions. Rightly or wrongly, I wanted to align them with Umbraco's namespaces for the view models.

I'll get a patch release out soon. ๐Ÿ‘ (I'm doing the usual juggling work/family/OSS ๐Ÿคท๐Ÿ˜†)

AaronSadlerUK commented 3 years ago

Thanks for the update @leekelleher, no rush from me... the beta is currently working fine, I was only updating prior to launch on Sunday (31st) evening :)

leekelleher commented 3 years ago

v3.0.1 patch release is out.