See the question and my original answer on StackOverflow

The template project (a project that only contains Visual Studio project templates or item templates) is only used to be able to work with templates. Its output (say [myproject].dll) is not important (the project type may be C# but it's irrelevant) and you will only distribute the .vsix file in the end.

Files (.vstemplate files and any other files) in this project are like "static" files. They will also ultimately be included into the .vsix file output during build.

So, to ensure this files (.cs or other) are "static", you must make sure they have their action set to None (for example), not Compile.