DefaultName Element (Visual Studio Templates)

Specifies the name that the Visual Studio project system will generate for the project or item when it is created.

<VSTemplate>
  <TemplateData>
    <DefaultName>

<DefaultName>
    Default Project Name
</DefaultName>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

None.

Parent Elements

Element

Description

TemplateData

Required element.

Categorizes the template and defines how it displays in either the New Project or the Add New Item dialog box.

Text Value

A text value is required.

This text specifies the default name of the project or item.

Remarks

DefaultName is an optional element.

For projects, this element specifies the name of the directory that stores the project on disk. For items, it specifies the file name of the source file.

When you create a project or item, you can modify the default name using the Name option, which is available from either the New Project Dialog Box or Add New Item Dialog Box.

If you do not want the project system to generate the default name for the project or item, then set the ProvideDefaultName element to False.

Example

The following example illustrates the metadata for the standard item template for a Visual C# class.

<VSTemplate Type="Item" Version="2.0.0"
    xmlns="https://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>MyClass</Name>
        <Description>My custom C# class.</Description>
        <Icon>Icon.ico</Icon>
        <ProjectType>CSharp</ProjectType>
        <DefaultName>MyClass.cs</DefaultName>
    </TemplateData>
    <TemplateContent>
        <ProjectItem ReplaceParameters="true">MyClass.cs</ProjectItem>
    </TemplateContent>
</VSTemplate>

See Also

Reference

Visual Studio Template Schema Reference

Other Resources

Visual Studio Templates