I have a c# project which includes several generated files (by T4) which are later included in compilation. The generation of code files itself works fine, but unfortunately incremental build sees generated files as a 'changes since last build' and re-builds the project each time. (For me it is a problem, since a large part of solution is rebuilt each time).
The warning from MSbuild looks like
The project does not appear up-to-date after a successful build: Input Compile item '...\DtoGenerator.generated.cs' has been modified since the last successful build started, not up-to-date. See https://aka.ms/incremental-build-failure.
Related part of the *csproj:
<ItemGroup><UpToDateCheckInput Remove="*.generated.cs" /><UpToDateCheckOutput Remove="*.generated.cs" /><UpToDateCheckBuilt Remove="*.generated.cs" /></ItemGroup><Target Name="TextTemplateTransform" BeforeTargets="BeforeBuild"><Exec WorkingDirectory="$(ProjectDir)" Command="dotnet t4 "%(TextTemplate.FullPath)" -P="$(ProjectDir)..\TextTemplating" -I="$(ProjectDir)..\TextTemplating"" /></Target>
I added ´UpToDateCheck*´ as per link proposed in warning, but it does not seem to work.
I have also seen the other proposed solution where "<Compile Remove" is used, and it does seem to help with up-to-date check, but this way the generated files are not included in compilation.
Have anyone encountered similar problem? How can I change the *.csproj to have the files generated before build and included during compilation, but excluding them from incremental build check?