Redigera

Dela via


CreateNewFolder element (Visual Studio templates)

Determines whether to check that the target directory where the project is to be created does not exist. If the directory does exist, a fresh directory can be created for the project. This setting is typically overridden by the NewProjectRequiresNewFolder(VsTemplate) registry flag (HKEY_LOCAL_MACHINE/SOFTWARE(/Wow6432Node)/Microsoft/VisualStudio/<version number>/Projects/<project GUID>) that all common project types use to determine whether to create a new project in a new directory.

<VSTemplate> <TemplateData> <CreateNewFolder>

Syntax

<CreateNewFolder>
    true/false
</CreateNewFolder>

Type

Boolean

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.

The text must be either true or false, indicating whether or not a new container folder should be created when a project is created from the template.

Remarks

CreateNewFolder is an optional element. The default value is true.

The value specified in the CreateNewFolder element is only honored by Visual Studio if the underlying project system supports it.

Example

The following code example specifies not to create a new folder when a project is created from the template.

<VSTemplate Type="Project" Version="3.0.0"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>My template</Name>
        <Description>A basic template</Description>
        <Icon>TemplateIcon.ico</Icon>
        <ProjectType>CSharp</ProjectType>
        <CreateNewFolder>false</CreateNewFolder>
    </TemplateData>
    <TemplateContent>
        <Project File="MyTemplate.csproj">
            <ProjectItem>Form1.cs<ProjectItem>
            <ProjectItem>Form1.Designer.cs</ProjectItem>
            <ProjectItem>Program.cs</ProjectItem>
            <ProjectItem>Properties\AssemblyInfo.cs</ProjectItem>
            <ProjectItem>Properties\Resources.resx</ProjectItem>
            <ProjectItem>Properties\Resources.Designer.cs</ProjectItem>
            <ProjectItem>Properties\Settings.settings</ProjectItem>
            <ProjectItem>Properties\Settings.Designer.cs</ProjectItem>
        </Project>
    </TemplateContent>
</VSTemplate>

See also