T4 for Sharp Architecture/Northwind Problem
Asked Answered
L

2

10

I have just downloaded sharparchitecture/Northwind and i'm trying to get crud scaffolding to work. I have changed nothing except adding missing reference to this class library. I try to run ScaffoldingGeneratorCommand.tt and I hit following 3 errors.

Error 1 Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration file:BaseTemplate.tt

Error 2 Compiling transformation: Class, struct, or interface method must have a return type file:BaseTemplate.tt

Error 3 Compiling transformation: Type expected file:BaseTemplate.tt

Compiler says they occur in the first line of BaseTemplate.tt but i don't think that is the true reason.

Has anybody had this problem? Do you have any idea what can i do to fix it?

Thanks a lot for your time, PK

Lingam answered 9/2, 2011 at 13:15 Comment(0)
M
34

I have received this using other T4 templates. The problem ends up being spaces at the end of the file (following the very last '#>' ).

Open your .tt file in VS, CTRL+END, make sure all spaces are removed following the last #>

 string someMethod()
 {
     //some code
    return "someValue";
 }
 #>

Props go to a post by Cheverton: http://social.msdn.microsoft.com/Forums/en-SG/vsx/thread/cd1217c1-39b0-4799-86a2-2449e21a8544

Mikesell answered 20/4, 2011 at 16:43 Comment(2)
bummer. What if your t4 outputs an xml and you want intellisense!?Lathan
In my case, I needed to do this on both T4MVC.tt and T4MVC.tt.hooks.t4 files.Pressing
P
5

I realize this is an old question, but I had the same problem just now, and in my case it turns out it was the line endings. They were LF, but needed to be CRLF.

After I made some edits to the .tt file, closed the editor, and opened it again, I had both LF and CRLF line endings in the same file, at which point Visual Studio offered to fix this for me. Once I had consistent CRLF line endings in the .tt file, it worked.

Pliam answered 9/4, 2014 at 15:32 Comment(4)
Also, I'd be happy to improve my answer if the downvoter would be kind enough to explain the downvote.Pliam
Ah, thank you Dhi, I was going MAD trying to find out this error... Damn Git and it's insistence to change line endings!Greyhound
You can configure how Git handles line endings. I had trouble with this, too, in the past.Pliam
Yes we have, but occasionally a project member or git client fails to do so, and madness ensues.Greyhound

© 2022 - 2024 — McMap. All rights reserved.