I\'m trying to create my own class template for Visual Studio called \"Public Class\".
I followed the official MSDN instructions on how to manually create an Item Templa
I had this problem :)
And I think I managed to solve it I was doing something very similar what I really wanted was to have a standard template which had headers in for our svn system I ended up extracting the existing Class.zip file in Foo:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033 and then editing it I ended up with this
// $Id$
// $Author$
namespace $rootnamespace$
{
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5) using System.Linq;
$endif$ using System.Text;
public class $safeitemrootname$
{
}
}
The spacing for the $if$ statement did seem to make a difference If I had tabs or spaced before them they would not evaluate properly or rather they did evaluate as you are seeing but were simply printed in my code.
As for your templates disappearing when you run /installvstemplates, well whats happening is you may notice that cmd takes quite a while to run, what it is infact doing is deleting Foo:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache and then rebuilding that folder by extracting the zip files in the original locations as mentioned above. For this command to behave visual studio is best shutdown whilst you run it and you should wait until the command has finished to restart it. (tip I used to actually monitor the folder and watch it build).
Personally allthough this is a flexible system microsoft really could have made this easier for the user, after all R# has this as a simple right click feature, if you have R# this is the easiest way to implement templates outside of the ms system.