为什么我的T4模板在文件名后添加数字? [英] Why does my T4 template append a number to the file name?

查看:97
本文介绍了为什么我的T4模板在文件名后添加数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的T4模板有时将数字附加到输出文件,有时却不附加数字?例如,在一种情况下,我可能有一个名为Foo.tt的模板文件,我将获得一个Foo.cs的输出文件.在其他情况下,我将得到一个Foo1.cs的输出文件. 在每种情况下,没有没有其他 Foo.cs文件可能会导致其附加数字.换句话说,这绝对不是任何明显文件的结果名称冲突.

Why do my T4 templates sometimes append a number to the output file and sometimes not? For instance, in one case I might have a template file called Foo.tt and I'll get an output file of Foo.cs. In other cases, I'll get an output file of Foo1.cs. In every case, there is no other Foo.cs file that might be causing it to append a number. In other words, it is definitely not the result of any obvious file name conflict.

我是一个深具保留性的肛门开发人员,因此,我很想知道如何摆脱这个无用的数字后缀.

I'm a deeply anal retentive developer, so I'd sure love to know how to get rid of that useless numeric suffix.

推荐答案

这种情况发生在Visual Studio感到困惑时,它会暂时出于某种原因(通常是幻觉的)确定它不能使用Foo.cs作为输出,因此会改用Foo1.cs,,然后坚持记住此设置.

This happens when Visual Studio gets itself confused and briefly decides that it can't use Foo.cs as the output for some reason (usually hallucinatory), so it will use Foo1.cs instead, and then insists on remembering this setting.

解决方法是在文本编辑器中打开.csproj文件,然后找到Foo.tt条目.这应该有一个名为LastGenOutput的子元素.将其更改回Foo.cs,保存项目文件,然后在VS中重新打开它.

The fix is to open the .csproj file in a text editor and locate the Foo.tt entry. This should have a sub-element called LastGenOutput. Change this back to Foo.cs, save the project file, and reopen it in VS.

然后-叹气-等待它再次发生.您可以看到 http://social. msdn.microsoft.com/Forums/zh-CN/linqtosql/thread/0c0f77a6-d712-43d2-a990-555df7960123 了解更多详细信息,尽管似乎没有人能够解释是什么原因导致VS进入此状态或如何停止这样做吧……

And then -- sigh -- wait for it to happen again. You can see http://social.msdn.microsoft.com/Forums/en/linqtosql/thread/0c0f77a6-d712-43d2-a990-555df7960123 for more details, though nobody seems to be able to explain what causes VS to get into this state or how to stop it doing so...

这篇关于为什么我的T4模板在文件名后添加数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆