Cannot re-create auto-generated classes

I am using Umbraco 13.1.1 and configured the Model Builder as follows:

  "Runtime": {
    "Mode": "Development"
  },
  "ModelsBuilder": {
    "Enable": true,
    "ModelsMode": "SourceCodeManual",
  }

On the Models Builder settings page I see:
Version: 13.1.1+cd47bdb

ModelsBuilder is enabled, with the following configuration:

The models mode is ‘SourceCodeManual’. Strongly typed models are generated on demand. Recompilation is necessary and models are available to all CSharp code.
Models namespace is Umbraco.Cms.Web.Common.PublishedModels.
Tracking of out-of-date models is enabled.
Models are out-of-date.

Until now I was able to click on the Generate models button and everything worked; until now.

I see that most of my 89 classes are deleted from the …/umbraco/models folder and the system started to recreate the …generated.cs files again; but fails to complete.
Build error messsage is something like:

E:\umbraco\prj\src\UmbracoProject\umbraco\models\SolutionItemSettings.generated.cs(23,69): error CS0246: The type or namespace name ‘IBlockVisibilitySettings’ could not be fou
nd (are you missing a using directive or an assembly reference?)

Some generated.cs files are recreated, but not all of them.
I can manually restore the deleted and not re-generated files and than the project complies again. But then still I do get the message that my “Models are out-of-date.”

How to I fix this issue. What causes this issue? Where is the problem?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/113668-cannot-re-create-auto-generated-classes