Quantcast
Channel: MSbuild up-to-date check for generated files does not work as needed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

MSbuild up-to-date check for generated files does not work as needed

$
0
0

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 &quot;%(TextTemplate.FullPath)&quot; -P=&quot;$(ProjectDir)..\TextTemplating&quot; -I=&quot;$(ProjectDir)..\TextTemplating&quot;" /></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?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>