dotnet / dotnet/project-system

Microsoft.TextTemplating.targets and FastUpToDate

Open
#9,477 6 comments 1 reaction 1 assignee Claimed by @drewnoakes View on GitHub
Feature-Up-to-date Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

The Microsoft.TextTemplating.targets will run t4 transformations on any .tt files in your project on build.
https://learn.microsoft.com/en-us/visualstudio/modeling/code-generation-in-a-build-process?view=vs-2022&tabs=csharp

However if a .tt file (and nothing else) is changed then FastUpToDate will prevent a rebuild (and thus prevent the t4 transform from rerunning).

Ideally Microsoft.TextTemplating.targets will add .tt files and their outputs to the appropriate UpToDate item groups.

I tried to work around this with

```





```

However that doesn't work if you have more than one .tt file you end up with a warning like the below and the build runs everytime.

```
WARNING: Potential build performance issue in 'MyProject.csproj'. The project does not appear up-to-date after a successful build: Input UpToDateCheckInput item 'C:\MyProject\File1.tt' is newer (2024-06-05 20:27:00.678) than earliest output 'C:\MyProject\File2.cs' (2024-06-05 20:26:28.652), not up-to-date. See https://aka.ms/incremental-build-failure.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.