开发者

T4 generating garbage ouput, tt file error free

开发者 https://www.devze.com 2023-01-05 10:55 出处:网络
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.

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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号