Solution2::GetProjectTemplate Method (String^, String^)

 

Returns a path to the indicated project template.

If a template has a RequiredFrameworkVersion element higher than 4.0, you should provide the version in the call so that the search for the template will find a match. For example, instead of calling GetProjectTemplate("Extensibility\\1033\\VSIXProject.zip", "CSharp"); call GetProjectTemplate("Extensibility\\1033\\VSIXProject.zip|FrameworkVersion=4.5", "CSharp");.

Namespace:   EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

String^ GetProjectTemplate(
	String^ TemplateName,
	String^ Language
)

Parameters

TemplateName
Type: System::String^

The name of the template.

Language
Type: System::String^

The language used to write the template.

Return Value

Type: System::String^

The full name of the project template.

Project templates are stored as zip files. This method asks for the project by name and language and returns the path to the template.

The parameters of GetProjectTemplate can be supplied in a number of different ways as shown below:

  • Pass in "CSharp" as the Language parameter, and the name of the zip file as the TemplateName.

    GetProjectTemplate("PocketPC2003-ClassLibrary.zip", "CSharp");
    
  • Pass in "CSharp" as the Language parameter, and a partial file path;" PocketPC2003\ClassLibrary.vstemplate", to uniquely specify the TemplateName.

    GetProjectTemplate("PocketPC2003\ClassLibrary.vstemplate", "CSharp");//partial file path
    
  • Pass in the string "CSharp" as the Language parameter, and the string "Pocket PC 2003 Class Library" for the TemplateName parameter. The string "Pocket PC 2003 Class Library" is derived from the folder hierarchy and is referred to as the user interface (UI) string. Other examples of UI strings are "Console Application" and "Windows Application".

    System_CAPS_noteNote

    The UI strings vary according to locale. Using the name of the zip file is the safest way to pass the TemplateName parameter.

    GetProjectTemplate("My Class Library", "CSharp");
    
  • Pass in the string "CSharp" as the Language parameter and the string "PocketPC2003\Pocket PC 2003 Class Library" for the TemplateName parameter. This includes the UI string and a partial path to uniquely specify the template.

    GetProjectTemplate("My3 Class Library", "CSharp");
    

You can also create your own custom project templates. To specify the directory in which you will store your templates, click Options on the Tools menu. On the left pane of the Options dialog box, click Projects and Solutions. Type the path for your templates in the Visual Studio user project templates location box. Alternatively, you can accept the default locations.

Custom templates require unique file names that do not conflict with the file names defined in:

  • <Visual Studio install directory\Common7\IDE\ProjectTemplates\Language 

Ensure that you use long file names (as opposed to 8dot3). For more information, see NIB: Creating Project and Item Templates.

No code example is currently available or this language may not be supported.
Return to top
Show: