views:

139

answers:

1

I've used SubSonic's ActiveRecord T4 templates in a couple of projects. Today I added the same templates from one of these projects (without the generated .cs source files) to a new project.

For some reason when I run the T4 template code generator, instead of generating:

ActiveRecord.cs, Context.cs, StoredProcedures.cs and Structs.cs

the template generator creates:

ActiveRecord1.cs, Context1.cs, StoredProcedures1.cs and Structs1.cs instead.

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.

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.

I'm using SubSonic 3.0.0.3.

Does anyone have any idea why this is happening?

+2  A: 

A solution is to delete the generated .cs files and edit the .proj file manually. Right click on the project in VS2008 and go unload project.

Search in the .proj file for ActiveRecord1.cs within LastGenOutput and change back to 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. That should get you going again.

Ah ha!....I'll remember that for the next time. Well done sir!
Kev
Thanks heaps for this information...
geocine