Share via


Project Template Generation Tool (Projectgen.exe)

The Project Template Generation tool (Projectgen.exe) can be used to create project templates for the Visual Studio integrated development environment (IDE) or the Visual Studio Tools for Applications IDE. Add-in developers use the project templates to create add-ins for the host application. You can run Projectgen.exe from the command line, or you can start the Project Template Generation wizard to walk you through the process of creating Visual Studio Tools for Applications project template files. For more information, see Creating Project Templates Using the Project Template Generation Tool (Projectgen.exe).

projectgen /i:path /o:path [/f] [/q] [/g]

Using Projectgen.exe

You can run Projectgen.exe in wizard mode or command-line mode. If you start Projectgen.exe from the command line and do not specify any parameters, the Project Template Generation wizard runs. You can specify template parameters in wizard mode, as shown in the Template Parameters section of this topic.

To run Projectgen.exe in command-line mode, you must pass a minimum of two parameters:

Arguments

The following table describes the arguments that are required to run Projectgen.exe in command-line mode.

Argument

Description

/xmlinput:full path

-or-

/i:full path

Specifies the name and location of an XML project descriptor file that provides information to generate the template file.

If the project descriptor file is not found or it does not conform to the required schema, Projectgen.exe throws an exception and stops processing.

/templateoutput:full path

-or-

/o:full path

Specifies the name and location of the .zip file for Projectgen.exe to use when it creates the file as output. The .zip file contains the generated Visual Studio project template files.

Note

The command-line options for Projectgen.exe are not case-sensitive and can be supplied in any order.

Options

You can pass the following optional parameters to Projectgen.exe.

Option

Description

/force

-or-

/f

Causes Projectgen.exe to overwrite any existing files. This parameter cannot be used on a specific file. If /force is specified, all output files are overwritten.

/help

-or-

/?

Displays help text. If /help or /? is present among the parameters, Projectgen.exe ignores any other command-line parameters.

/nologo

-or-

/g

Suppresses banner text.

To create a project template, use the input path and output path as shown in the following code example.

projectgen.exe /i:=InputDescriptorFile /o:=OutputProjectTemplate

For an example of how to use Projectgen.exe parameters to create a project template, see How to: Create a Project Template Using the Projectgen.exe Command-Line Tool.

Template Parameters

When you run the Project Template Generation wizard, there are a number of template parameters that you can use as replacement variables in various parts of the project template files. You typically type these in the Debug Command Line box on the Project Properties page of the wizard, but you can also use them if you manually modify the template files. The following table describes commonly used variable replacements for Visual Studio Tools for Applications.

Variable

Description

$itemName$

The user-provided name of an item template being added to a project. This is used to replace class names in class file templates or form file templates.

$safeitemname$

The user-provided name of the item with all unsafe characters and spaces removed.

$saferootitemname$

The name of the root item. This is used for multi-file items when the root item name should be used for all parameter replacements.

$guid[1-10]$

A globally unique identifier (GUID) that is used to replace the project GUID in a project file. The user can specify up to 10 GUIDs.

$projectname$

The user-provided name of the project for a project template.

$safeprojectname$

The user-provided name of the project for a project template with all unsafe characters and spaces removed. This is used to replace the namespace and the name of the main class in some templates.

$rootnamespace$

The root namespace of a project for an item template being added to a project. This is used to replace the namespace of the item in the item file.

$time$

The current time in the format DD/MM/YYYY HH:MM:SS.

$year$

The current year in the format YYYY.

$username$

The current user name.

$userdomain$

The current user domain.

$machinename$

The current computer name.

$clrversion$

The current version of the common language runtime (CLR).

$registeredorganization$

The registry key value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization. This is used for the company name field in AssemblyInfo.vb or AssemblyInfo.cs.

$wizarddata$

The contents of a WizardData element. This is passed as a single string. For more information, see WizardData Element (Visual Studio Templates).

$(OutputPath)

The path to the output directory.

$(AssemblyName)

The name of the assembly that is compiled to the output directory.

%environmentvariable$

An environment variable to replace. This only applies to the <projectproperties> section of the project file.

#RegKey#

The full path of a registry key value. This only applies to the <projectproperties> section of the project file.

$(MSBUILDVAR)

MSBuild reserved properties that store information about the project file. For more information, see MSBuild Reserved Properties.

For an example of how to use the Project Template Generation wizard to create a project template, see Walkthrough: Creating a Project Template Using the Project Template Wizard.

See Also

Tasks

How to: Create a Project Template Using the Projectgen.exe Command-Line Tool

Walkthrough: Creating a Project Template Using the Project Template Wizard

Concepts

Creating Project Templates (Visual Studio Tools for Applications)

Creating Project Templates (Visual Studio Tools for Applications)

Creating Project Templates Using the Project Template Generation Tool (Projectgen.exe)

Creating Proxies