简体   繁体   中英

How to MS T4 TextTemplating during build working again

I don't know when the problem started happening but I believe it would have been after 5 months ago because that is the last time I did an update for https://github.com/innovoft/Innovoft.IO.SplitReaders https://www.nuget.org/packages/Innovoft.IO.SplitReaders . But at some point the T4 import stopped generating files. I only noticed because I started a new project that I need to follow the same basic setup, and it didn't work. I deleted the *.tt.cs files in Innovoft.IO.SplitReaders and the test project no longer worked, so the problem could be older than 5 months.

Steps to Reproduce:

  1. download https://github.com/innovoft/Innovoft.IO.SplitReaders
  2. build test (only building the library works because otherwise nothing is calling one of the generated methods such as ReadColumnsAdd)

Here is the sections from the csproj file related to T4 that has worked in the past. I don't know how to quote xml.

PropertyGroup
TransformOnBuild: true
OverwriteReadOnlyOutputFiles: true
TransformOutOfDateOnly: false

Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets"

Expected Behavior:
T4 create *.tt.cs files that will compiled

Actual Behavior:
As far as I can tell nothing is happening with the T4s.

Check the value of VSToolsPath being used during the build: it's probably not being set.

Try the following instead (assumes you are using VS2022):

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v17.0\TextTemplating\Microsoft.TextTemplating.targets" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM