If you don’t like some item templates in Visual Studio, there are two ways to tackle the problem: create a new custom template (recommended way) or change the existing one.
To create a new custom template you should standard functionality of Visual Studio via using File -> Export Template menu. There are two great articles explaining how to do that:
- MSDN: Create Reusable Project And Item Templates For Your Development Team
- CodeBeter.com: Creating Custom Item Templates in Visual Studio 2005
Note that the first way is recommended and using the second one described below may damage your Visual Studio installation.
To change existing template you have to do some manipulations specified below. Further instructions are based on the assumption that we want to change the C# class template for Visual Studio 2005 installed in default location.
1. Find the code file template here:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip
2. Copy original Class.zip file somewhere (and also make a second backup copy of it)
3. Extract copied Class.zip and open Class.cs file in test editor. You should see following:
4. Modify the class template you wish. I have removed using directives, added public modifier for class and added the default class constructor:
5. Save the changes
6. Archive modified template back using standard Compressed Folder from Explorer:
7. Replace original Class.zip file with new one
8. Open Visual Studio 2005 Command Prompt and execute following command to refresh the templates:
devenv.exe /installvstemplates
9. Open IDE, create a new C# project and add a new class:
That's all.
Keep in touch and happy extending!
No comments:
Post a Comment