Sunday, August 31, 2008

changing the class item template in VS2008

It's been bugging me for too long, every bloody time I go new -> class in VS2008,
I get a class that is not set to public. I usually don't realize until I try to use the class at some later time.

Today I finally snapped and fixed it.

To change the template that is used to create new empty classes in VS2008,
- Go to 
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
- unzip the
- change the class.cs file
- zip it back up and replace the original .zip file.

In yo face VS2008 default settings!!


Erlend said...

Nice. By editing the SimpleUnitTest template I can also get rid of all the crappy outcommented stuff.

boomshanka said...

As a note there seems to be a folder called "ItemTemplatesCache" (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Code\1033) in which you also need to update for it to work, but I'm sure there's another way of doing this.

For those using the express editions, the files can be located here:

[drive]:\[programs directory]\Microsoft Visual Web Developer 2008 Express\Common7\IDE\[express edition]\ItemTemplates\1033

[drive]:\[programs directory]\Microsoft Visual Web Developer 2008 Express\Common7\IDE\[express edition]\ItemTemplatesCache\1033

You can replace [express edition] with VCSExpress (Visual C# Express Edition), VWDExpress (Visual Web Developer Express) and so forth. The paths might also depend on which Edition you installed first, but you get the point.

Harry said...

I changed all class1.cs to our template, but when I use the toolbox to add a class unto the class-diagram, our template is not used. Do you know were this template can be found?