Skip to content

SingleFileGenerator only works for old-style projects, not for SDK projects #290

@peter-sabath

Description

@peter-sabath

Installed products

Visual Studio 2022 Community

Description

I have a SingleFile generator that works fine for old-style projects, but does not get executed for SDK-style projects (.NET 8)
The package has those CodeGenerator-related attributes:

[ProvideCodeGenerator(typeof(BuildTextConsts), BuildTextConsts.Name, BuildTextConsts.cCustomToolDescription, true, ProjectSystem = ProvideCodeGeneratorAttribute.CSharpProjectGuid, RegisterCodeBase = true)] [ProvideCodeGeneratorExtension(BuildTextConsts.Name, BuildTextConsts.cDefaultExtension)]

I also added the custom command from your Single-File Generator example to add/set the custom build tool entry.
The command gets executed for both project styles, but the generator is only used for old-style projects.

As the availability is only declared via Attributes I have no idea how to debug this and find a reason why it does not work for SDK-style projects.

Because the SDK style projects are projects that were migrated from older when migrating from .NET Framework to .NET 8 I also tried it with clean, empty projects of both styles with the same result.

Expected behavior

Should work with both types of projects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions