Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8: models builder generated models - this.Value<type> #4780

Closed
steadygo opened this issue Feb 27, 2019 · 7 comments
Closed

V8: models builder generated models - this.Value<type> #4780

steadygo opened this issue Feb 27, 2019 · 7 comments

Comments

@steadygo
Copy link

Fresh install of Umbraco 8.0.0 configured to utilise separate models project fails to find property of this.Value<type> in generated models.

Reproduction

Fresh Install from UaaS.cmd

Add Umbraco.Web.PublishedContentModels project and configure web.config

Add Nuget for UmbracoCMS.Core and Umbraco.ModelsBuilder and reference System.Web in new project

Add references as appropriate to CORE and WEB

Bug summary

The generated models comprise calls to return values by type, these calls fail to compile with error regarding failure to find definition or extension method for Value

Specifics

Umbraco 8.0.0 downloaded from git repo via UaaS.cmd
UmbracoCms.Core (8.0.0) nuget
Umbraco.ModelsBuilder (8.0.1) nuget

Steps to reproduce

Fresh Install from UaaS.cmd

Add Umbraco.Web.PublishedContentModels project and configure web.config

<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
<add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/../Umbraco.Web.PublishedContentModels" />
add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true" />

Add nuget packages UmbracoCms.Core (8.0.0) and Umbraco.ModelsBuilder (8.0.1), add reference to System.Web

Reference new project Umbraco.Web.PublishedContentModels in both core and web projects.

Build, navigate to CMS and publish the content models.

Refresh Umbraco.Web.PublishedContentModels project and include the cs files for File, Image, Folder, Member

Attempt to Build

Expected result

Compiled solution ready to run

Actual result

Failure to compile with errors in generated cs files in Umbraco.Web.PublishedContentModels, E.g.

Error CS1061 'File' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'File' could be found (are you missing a using directive or an assembly reference?) Umbraco.Web.PublishedContentModels C:\sg-htdocs\u8-jo\Umbraco.Web.PublishedContentModels\File.generated.cs 53 Active

image

@pc-pdx
Copy link

pc-pdx commented Feb 28, 2019

fwiw: i was able to resolve this by updating my projects TargetFramework to .net v4.7.2 as that is what the umbraco8 dlls are compiled against 👍

@mattbirch
Copy link

Same issue. Seems like the .Value and .Value extension methods used by ModelsBuilder are in the Umbraco.Web dll and so installing UmbracoCms.Core in the models project isn't sufficient.

Solved for now by manually copying the Umbraco.Web dll over to the other project and referencing it, but that's not ideal.

@steadygo
Copy link
Author

I

fwiw: i was able to resolve this by updating my projects TargetFramework to .net v4.7.2 as that is what the umbraco8 dlls are compiled against 👍

I think that is a solution to a problem I'm not having.

I suspect that is because your model builder is targeted to the same project as the main project so once you made the target the correct framework then all was well and of the Umbraco.Web.dll (as referred to by mattbirch) was already present?

@steadygo
Copy link
Author

Same issue. Seems like the .Value and .Value extension methods used by ModelsBuilder are in the Umbraco.Web dll and so installing UmbracoCms.Core in the models project isn't sufficient.

Solved for now by manually copying the Umbraco.Web dll over to the other project and referencing it, but that's not ideal.

I can confirm this worked for me! I downloaded via nuget. There is a nuget package for it. UmbracoCms.Web

@nul800sebastiaan
Copy link
Member

Solved for now by manually copying the Umbraco.Web dll over to the other project and referencing it, but that's not ideal.

How about Install-Package UmbracoCms.Web?

For you @steadygo - it's the same problem, you are missing the assembly reference to Umbraco.Web. It sounds like the problem for everyone is missing references / framework versions. With a new version things are done a bit differently than on v7 and one of the differences is the NEW NuGet package UmbracoCms.Web.

Give it a go, adding it worked for me with the config you mentioned above! 👍

@mattbirch
Copy link

Ah perfect, I should have searched Nuget! Thanks @nul800sebastiaan

@bronzewind
Copy link

bronzewind commented Mar 26, 2019

UmbracoCms.Web

Absolutely true. Solved by doing Install-Package UmbracoCms.Web @ the Core Project

This is an excellent article https://anotherdevblog.com/2018/07/18/organize-an-umbraco-projects/ that suggests this workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants