Tip

Copy a project template

Please let other users know how useful this tip is by rating it below. Got a tip or code of your own you'd like to share? Submit it here!


You can extend Visual Studio .NET by adding custom project templates. This tip, excerpted from InformIT

    Requires Free Membership to View

, demonstrates how to copy a project template from the existing set of templates that comes with Visual Studio.NET. The entire article on InformIT has more information, such as custom attributes and class libraries.

A class library is simply a DLL, and custom attributes are classes that inherit from System.Attribute, allowing you to define additional metadata to incorporate into your .NET assemblies. (Metadata is information added to .NET assemblies to help mitigate "DLL Hell.").

Select File, New, Project to open the New Project dialog box, which displays a list of project types from which you can select. (You get the greatest selection of new kinds of projects with Visual Studio .NET Enterprise Architect.) These project templates contain elements that are fundamental for the selected type of application. For example, if you select the Console Application template, you get a project that contains a class with a static main method. This static main method is the entry point for a console application.

And here's the advantage of using project templates: You might normally have to work to discover that a console application has a static main method that uses the Single-Threaded Apartment threading model (STAThread) attribute, but the Console Application project template takes care of this detail for you.

The easiest way to create a project template is to copy an existing project template. Existing project templates are defined in folders in C:Program FilesMicrosoft Visual Studio .NETVC#VC#Wizards, if you use the default installation folder for Visual Studio .NET. The CSharpDLLWiz folder contains a project template close to the one that we want to create for this example, so we'll copy this project template.

To copy the project template, follow these steps:

  1. In Windows Explorer, copy the C:Program FilesMicrosoft Visual Studio .NETVC#VC#WizardsCSharpDLLWiz folder.
  2. Paste the folder in C:Program FilesMicrosoft Visual Studio .NETVC#VC#Wizards. This step will create a folder named Copy of CSharpDLLWiz.
  3. Assign a new name to the copied project template folder. For this example, I used the name CSharpAttrWiz. (You can use any name you want.)

The new folder contains Scripts and Templates subfolders. These subfolders contain files that support the wizard behavior, including template files that are used to generate the source code files in each new project created from the template.


To read the entire article from which this tip is excerpted, click over to InformIT. You'll have to register to read it, but hey, the registration is free.


This was first published in November 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.