Skip to content

When using output extension directive with .gen.cs, the final file becomes xxx.gen.gen.cs #7

@scottbilas

Description

@scottbilas

Problem

I have this directive in my .tt file:

<#@ output extension=".gen.cs" #>

When using VS or Rider's built-in text templating, this produces an output <filename>.gen.cs. But when using T4.Build, it outputs <filename>.gen.gen.cs.

Solution (my guess)

I don't know how to debug an msbuild task, but looking through the code it appears this is caused by (T4.Build) BuildTemplateGenerator.OutputFile doing a Path.ChangeExtension before (Mono.TextTemplating) TemplateGenerator.SetFileExtension does the same thing.

When using an ordinary extension (.xyz) the double-call doesn't change anything. When using a doubled extension (.xyz.abc) the "sub"-extension gets doubled up, resulting in the <filename>.gen.gen.cs I mentioned above.

My guess on a fix would be, within BuildTemplateGenerator.OutputFile, to only change extension if no output directive is found.

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