Unable to regenerate ModelsBuilder .generated.cs files after upgrading from Umbraco 13.16.0 to 17.5.3

Hi Team,

Currently we are upgrading Umbraco v13.13.1 to Umbraco v17.5.3.

Steps we followed till now.

  1. Upgrade Umbraco v13.13.1 to v13.16.0 → dotnet restore and Build was successfully done.
  2. Upgrade .NET 8 to .NET 10 → dotnet restore and Build was successfully done.
  3. Upgrade Umbraco v13.16.0 to v17.5.3 → Updated NuGet packages and resolved several dependency/build issues. Now 160 build errors remains those all are from *.generated.cs files. which was present in MastiffUmbraco.Models\PageModels folder. please check the build error in attached screenshot.

Additional information:

The project was using:
“ModelsBuilder”: {

“ModelsMode”: “SourceCodeAuto”,

“ModelsNamespace”: “MastiffUmbraco.Models”,

“ModelsDirectory”: “~/../MastiffUmbraco.Models/PageModels”,

“AcceptUnsafeModelsDirectory”: true,

“FlagOutOfDateModels”: true

}

Can some one help us to resolve this build errors ? (regenerating files in Umbraco 17 )

Hi there,

If you try replacing ‘IPublishedSnapshotAccessor’ with ‘IPublishedContentTypeCache’, in each of the generated files, that may get it building

There’s some info in the docs of the changes here: Breaking Changes Overview | CMS 17.latest (LTS) | Umbraco Documentation

This may be of use..
Quick fix for IPublishedSnapshotAccessor issues when upgrading to Umbraco 17 | skttl.dev

The reason is that Umbraco 15 introduced a new cache, the HybridCache, that replaced the NuCache that Umbraco used up until that point. That also introduced some new services and removed some older services like you see here.

Ps also of note in recent versions this modelsBuilder setting..

      "ModelsBuilder": {
        "IncludeVersionNumberInGeneratedModels": false
      }

stops the plethora of changed modelsbuilder generated files in sourcecontrol just for an umbraco version update.. I’ve not seen any downsides to not having the version stamp.. others may disagree..

Models Builder Settings | CMS | Umbraco Documentation

@Luuk Re: NuCache gone and hybridCache now reminded me we still have remnants of Nu… cmsContentNu table :slight_smile: