The command-line mode is useful if you want to automate project template creation as part of the build process. Before you run Projectgen.exe in command-line mode, you must complete the following prerequisites:
Register your host application. For more information, see How to: Register the Host Application.
Create a proxy DLL that describes the object model of your host application. The proxy DLL can be generated by using the Proxy Generation tool (Proxygen.exe). For more information, see Creating Proxies and Proxy Generation Tool (ProxyGen.exe).
Create an XML project descriptor file. The Project Template Generation wizard generates this file automatically, so you can run Projectgen.exe in wizard mode and then use the output file as input for command-line mode. You can also create the file manually. For more information, see Descriptor Schema for Projectgen.exe.
Running Projectgen.exe from the Command Line
When you run Projectgen.exe from the command line, you must pass the necessary input and output parameters, in addition to any optional parameters. The XML project descriptor file is a required input parameter. For more information, see Project Template Generation Tool (Projectgen.exe).
You specify the location where you want to store the template project in an output parameter. This location should be the same location specified by the ProjectTemplatesLocation registry key that was created when you registered the host, but you can modify the location.
Projectgen.exe Output
Projectgen.exe generates project templates for Visual Basic and Visual C# and then saves the templates in subfolders of the project template location you specified. For example, the following command uses an XML project descriptor file named projectdescriptor.xml to create project templates under C:\MyApp\ProjectTemplates.
projectgen.exe /i:"C:\MyApp\projectdescriptor.xml" /o:"C:\MyApp\ProjectTemplates\"
You can register the templates with the host application by registering the host application. If you specify a location for the project templates that is different from the location that is specified in the registry, you must copy the project templates to the location specified in the registry before registering the host application. For more information about registering a host application, see How to: Register the Host Application.
XML Project Descriptor File
The XML project descriptor file contains the data needed to create a project template, including the following information:
A <TemplateProperties> node that contains information about the template, such as the name of the template as it will appear in the Visual Studio Add Project dialog box, a description of the template, and the icon to be associated with the template.
A <ProjectProperties> node that contains information about the project, such as the project name as it will appear in Project Explorer, the host identifier, and information about any host items in the project. This section of the XML project descriptor file also contains any references to managed assemblies and COM assemblies.
The location of the proxy DLL, indicated in the <ProxyAssemblyName> node.
The XML project descriptor file must be based on a specific schema. For more information, see Descriptor Schema for Projectgen.exe. The following is an example of an XML project descriptor file.
<ProjectGen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TemplateProperties>
<Name>ShapeAppMFC Add-in</Name>
<Description>A project for creating add-ins for
ShapeAppMFC</Description>
<DefaultProjectName>ShapeAppMFC</DefaultProjectName>
<Icon>C:\ShapeAppSamples\ShapeAppIcon.ico</Icon>
</TemplateProperties>
<ProjectProperties>
<HostName>ShapeAppMFC</HostName>
<DebugInfoExeName>C:\ShapeAppSamples\ShapeAppMFC\
debug\ShapeAppMFC.exe</DebugInfoExeName>
<DebugInfoCommandLine />
<HostIdentifier>ShapeAppMFC</HostIdentifier>
<IconImageList />
<HostItems>
<HostItem>
<ProxyAssemblyName>C:\ShapeAppSamples\ShapeAppMFCLib\
ShapeAppMFCLib\bin\Debug\ShapeAppMFCLib.dll</ProxyAssemblyName>
<HostItemName>ThisApplication</HostItemName>
<BaseType>ShapeApp.Proxy.ApplicationEntryPoint</BaseType>
<PrimaryCookie>ThisApplication</PrimaryCookie>
</HostItem>
</HostItems>
<References>
<Reference Include="System.Windows.Forms" />
</References>
<COMReferences>
<COMReference Include="MAPI">
<Guid>3fa7dea7-6438-101b-acc1-00aa00423326</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>21</VersionMinor>
<WrapperTool>Tlbimp</WrapperTool>
</COMReference>
</COMReferences>
</ProjectProperties>
</ProjectGen>