Skip to content

Exception: MyGenerationSpec not found #217

@JPtenBerge

Description

@JPtenBerge

I'm on a .NET 9 project and getting an exception:

PM> TypeGen generate
Generating files for project "."...
TypeGen : Unhandled exception: TypeGen.Cli.CliException: Type 'MyGenerationSpec' not found in TypeGen.Core or any of the assemblies: 'MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

I'm trying to use TypeGen for the first time. Installed the TypeGen NuGet package, added tgconfig.json, added MyGenerationSpec.cs and tried to run TypeGen generate:

Config and gen spec are straight from the docs:

{
	"generationSpecs": ["MyGenerationSpec"]
}
public class MyGenerationSpec : GenerationSpec
{
	public MyGenerationSpec()
	{
		AddClass<MyDto>();
	}
}

I've:

  • Triple-checked the config and filenames, built everything, built in Debug configuration so the class wouldn't get optimized away during compilation, checked with ILSpy that the class really was in the assembly. It's there.
  • Tried adding a namespace to the MyGenerationSpec , tried removing it, tried placing it in a subfolder. Rebuilt everything after every change.
  • Tried the dotnet tool instead of using the Package Manager Console, same exception.

If I try not using generationSpecs, but use [ExportTsClass] above my classes, then it doesn't give me an exception anymore, it just doesn't output anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions