modelsbuilder / ModelsBuilder.Original

The Community Models Builder for Umbraco
MIT License
114 stars 49 forks source link

VS Extension: Method not found: 'System.String Umbraco.ModelsBuilder.Building.Compiler.CreateValidIdentifier(System.String)' #238

Open hfloyd opened 4 years ago

hfloyd commented 4 years ago

I have been happily using the CustomTool version for years, but today decided to get with the program and install the newer VS Extension. When I ran "Build Models..." I get a dialog mentioning a failure and the output window says:

UmbracoModelsBuilder: Starting v8.1.1 7/20/2020 4:42:06 PM.
UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: MissingMethodException: Method not found: 'System.String Umbraco.ModelsBuilder.Building.Compiler.CreateValidIdentifier(System.String)'.
UmbracoModelsBuilder:    at ZpqrtBnk.ModelsBuilder.Extension.Generator.GetNameSpace(String path)
   at ZpqrtBnk.ModelsBuilder.Extension.Generator.TryGenerate(ProjectItem sourceItem)
   at ZpqrtBnk.ModelsBuilder.Extension.Generator.Generate(AsyncPackage package, ProjectItem sourceItem)

This is my models folder structure: image

The "ContentTypes" folder is not included in any project namespaces - it is just to separate "Umbraco Content Type-based" models from any other custom models needed.

My "_ModelBuilderConfig.cs" file includes an explicit namespace:

using Umbraco.ModelsBuilder;
[assembly: ModelsNamespace("MySite.Models")]

Perhaps this is related to this other issue: https://github.com/modelsbuilder/ModelsBuilder.Original/issues/228 ?

EelmanE commented 3 years ago

not sure if this is still a problem, but i just ran into this today and my solution was to disabled (or remove) the old visual studio extension for modelsbuilder

ProNotion commented 2 years ago

@hfloyd I'm sure you are well past this already but I've hit the same issue in an old project and solved it so I will leave this comment here for anyone else that might have the problem including my future self. Coming from the previous version of the tool I had a .cs file I used to generate the classes previously. At some point I had removed the contents of the file. Adding the namespace in the file with no class made the error go away. That said, I removed the .cs file anyway afterwards to use this new method with the .mb file.

@EelmanE Your solution also helped me with another issue I had when running the tool 👍