![]() |
Platforms, Frameworks & Libraries »
.NET Framework »
General
Intermediate
License: The Code Project Open License (CPOL)
Templates in Visual Studio .NETBy Ricardo CasqueteThis article shows the way to create templates for Visual Studio .NET |
Windows, .NET, Visual Studio, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Creating templates for Visual Studio is, in my opinion, funny, useful and easy.
This article shows the way to create your own templates for Visual Studio. I have found little information about this issue.
Some points I have found useful for templates are:
#region you want for public/protected/private methods/properties/vars/const/constructors… All information about the templates of Visual Studio are stored in the folder: c:\[ProgramFiles]\ Microsoft Visual Studio .NET 2003\VC#.
The important part of the structure of this folder is this:
To add a template, you only have to add a folder and files in that folder with the same structure. That’s why I think the easiest way to do it, is using a Deploy Project.
The folder we have to pay attention to, as I have said before, is c:\[ProgramFiles]\ Microsoft Visual Studio .NET 2003\VC#.
We must pay attention to the folders: CSharpProjectsItems and VC#Wizards.
These folders also contain the vsz files that point to the Wizards (see below).
Example of the Data Inside and the fields that must be modified to create our own templates.
..\..\CSharpAddBLLWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|Business Logic Layer ( BLL )|11|Class for the Business Logic Layer, with Samples|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4801|0|EnterpriseBLL.cs
..\..\CSharpAddClassWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|Enterprise Class|10|Class with the Enterprise Format|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4801|0|EnterpriseClass.cs.
If you try to open other's vsdir files, like the DataSet, WebService… maybe you will find that instead of the Text for some of the fields there is a number… this number as in the icon case, is the ID of the string embedded in the csproj.dll, that contains the text to display.
Example of the data in the file:
VSWIZARD 7.0
Wizard=VsWizard.VsWizardEngine.7.1 Param="WIZARD_NAME = CSharpMyTemplateBLL"
Param="WIZARD_UI = FALSE"
Param="PROJECT_TYPE = CSPROJ"
You can see other's file and change what you want; the only important point here is to write the Name of the Wizard properly, it must be the same that a folder contained in the VC#Wizards folder. because when you select the template that points to the vsz, the name of the wizard will be the one that will be executed.
As I have mentioned before, the vsdir is all the information to display the item.
Most of the Icons of the templates are stored in a DLL called csproj.dll that is located in the folder, C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\vcpackages.
If you open it with Visual Studio, it is easy to see the Icons or add a new one.
..\..\CSharpAddClassWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|Enterprise Class|10|Class with the Enterprise Format|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4801|0|EnterpriseClass.cs
In my example for the seventh field, I have written 4801 that is the ID (or Name) of the Icon I have added to csproj.dll.
To see the Icon over the template in Visual Studio AddNewItem Menu, as I have mentioned before, to the csproj.dll an Icon must be added with the ID of the one referenced in each line of the vsdir files.
Instead of creating a Custom Action to add the resource, I have added a Custom Action to copy my DLL Icon with the new Icon. This craps a bit, the right solution should be, instead of delete and copy a new DLL, to open it with an instance of System.Resources.ResourceWriter and add the Icon.
As you can see in the article, adding a template for Visual Studio .NET 2003 is a simple task, I am sure you'll find it at least interesting apart from amusing.
Right now, I am trying to find out the way to create templates for Visual Studio .NET 2005. I hope it will be as easy as in 2003.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 27 Mar 2006 Editor: Deeksha Shenoy |
Copyright 2006 by Ricardo Casquete Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |