I'm trying to create a T4 template to generate a c开发者_如何学编程lass for a specific task I need. However, something is broken with its output.
The output file contains random garbage characters even when the .tt file is blank. I'm thinking it's something to do with the character encoding on the .tt file, maybe.
I can successfully add a code generation item to an edmx file and it will generate fine unless I make a change to the tt file, save, revert the change, resave. The output becomes garbage again.
Haven't been able to find anyone else experiencing this issue.
Example: TextTemplate.tt
<#@ template debug="false" hostspecific="false" language="C#" #>
Output file: TextTemplate.cs
믯㲿䀣琠浥汰瑡敤畢㵧昢污敳•潨瑳灳捥晩捩∽慦獬≥氠湡畧条㵥䌢∣⌠ാ
Ideas, anyone?
Thanks,
Carl
Managed to work around this by doing Right Click -> Open With -> Source Code (Text) Editor With Encoding. Picked up fine with Encoding: (Auto-Detect)
Have a look at the output file in binary. It's possible that it's actually in UTF-8 or ASCII, but that Visual Studio thinks it's in UTF-16. Can you post the first few characters of what you'd expect, and their binary output? (If you could post the binary input as well, that would help.)
精彩评论