简体   繁体   English

为什么SubSonic的ActiveRecord T4模板会生成ActiveRecord1.cs而不生成ActiveRecord.cs?

[英]Why does SubSonic's ActiveRecord T4 template generate ActiveRecord1.cs and not ActiveRecord.cs?

I've used SubSonic's ActiveRecord T4 templates in a couple of projects. 我在几个项目中使用过SubSonic的ActiveRecord T4模板。 Today I added the same templates from one of these projects (without the generated .cs source files) to a new project. 今天,我将其中一个项目(没有生成的.cs源文件)中的相同模板添加到新项目中。

For some reason when I run the T4 template code generator, instead of generating: 出于某种原因,当我运行T4模板代码生成器时,而不是生成:

ActiveRecord.cs , Context.cs , StoredProcedures.cs and Structs.cs ActiveRecord.csContext.csStoredProcedures.csStructs.cs

the template generator creates: 模板生成器创建:

ActiveRecord1.cs , Context1.cs , StoredProcedures1.cs and Structs1.cs instead. Context1.csActiveRecord1.csContext1.csStoredProcedures1.csStructs1.cs

I've deleted all the .cs sources files in the ActiveRecord folder and there are no other files with these names across the whole solution. 我删除了ActiveRecord文件夹中的所有.cs源文件,并且在整个解决方案中没有其他具有这些名称的文件。

Whilst this is not a problem, because the correct classes, namespaces etc are generated, it's annoying to see the number 1 tacked on the end of the filenames. 虽然这不是问题,因为生成了正确的类,命名空间等,但是看到在文件名末尾加上数字1是很烦人的。

I'm using SubSonic 3.0.0.3. 我正在使用SubSonic 3.0.0.3。

Does anyone have any idea why this is happening? 有谁知道为什么会这样?

A solution is to delete the generated .cs files and edit the .proj file manually. 解决方案是删除生成的.cs文件并手动编辑.proj文件。 Right click on the project in VS2008 and go unload project. 右键单击VS2008中的项目并卸载项目。

Search in the .proj file for ActiveRecord1.cs within LastGenOutput and change back to ActiveRecord.cs. 在.proj文件中搜索LastGenOutput中的ActiveRecord1.cs并更改回ActiveRecord.cs。 repeat for the other files. 重复其他文件。 Somehow these names are incremented. 不知何故,这些名称增加了。

<None Include="T4AutoGen\ActiveRecord.tt">
  <Generator>TextTemplatingFileGenerator</Generator>
  <LastGenOutput>ActiveRecord.cs</LastGenOutput>
</None>

Save the file an reload the project. 保存文件并重新加载项目。 Your files should generate correctly now. 您的文件现在应该正确生成。

I am not sure why this happens other than some weirdness with t4 templates. 我不确定除了t4模板的一些奇怪之外,为什么会发生这种情况。 That should get you going again. 这应该让你再次前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM