I'm trying to do something similar to Get Visual Studio to run a T4 Template on every build using cmd's forfiles
to transform each template in VS2008.
If I execute
forfiles /m "*.tt" /s /c ""%CommonProgramFiles(x86)%Microsoft SharedTextTemplating1.2TextTransform.exe" @file"
then I get TextTransform.exe
's error message (the screen of text explaining what to pass it as arguments).
If I instead execute
forfiles /m "*.tt" /s /c "cmd /c echo Transforming @path && "%CommonProgramFiles(x86)%Microsoft SharedTextTemplating1.2TextTransform.exe" @file"
then it works perfectly.
In order to debug this, I created a simple command-line program called debugargs
which simply prints the number of arguments it receives and their values. Then some experimentation shows that the first form of directly passing the command to forfiles
causes the first argument to be swallowed. E.g.
forfiles /m "*.tt" /s /c "debugargs.exe 1 2 3"
gives output
2 arguments supplied
#1: 2
#2: 3
The documentation I've been able to find is quite sparse, and I don't see any mention of this as a possibility. Is it just an obscure bug, or am I missing something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…