Project 元素 (Visual Studio 範本)

指定要加入至項目的檔案或目錄。

<VSTemplate><TemplateContent><專案>

語法

<Project
    File="MyProject.proj"
    TargetFileName="MyTargetProject.proj"
    ReplaceParameters="true/false">
    IgnoreProjectParameter="$myCustomParameter$"
        ...
</Project>

屬性和元素

下列章節將說明屬性、子項目和父項目。

屬性

屬性 描述
File 必要屬性。

指定範本 .zip 檔中的項目檔名稱。
ReplaceParameters 選用屬性。

布爾值,指定項目檔是否具有從範本建立項目時必須取代的參數值。 預設值為 false
TargetFileName 選用屬性。

從範本建立專案時,指定項目檔的名稱。
IgnoreProjectParameter 選用屬性。

指定專案是否應該新增至目前的方案。 如果自定義參數的值 「$myCustomParameter$」 存在於參數取代檔案中,則會建立專案,但不會新增為目前開啟解決方案的一部分。

子元素

元素 描述
資料夾 選擇性項目。

指定要加入至項目的資料夾。
ProjectItem 選擇性項目。

指定要加入至項目的檔案。

父元素

元素 描述
TemplateContent 必要項目。

備註

ProjectTemplateContent 的選擇性子項目。

元素 Project 是用來指定專案,因此只有在專案範本中才有效。

Project元素可以有 Folder 子專案或 ProjectItem 子專案,但不能Folder混合使用 和ProjectItem子元素。

Visual Studio 會根據使用者在 [ 新增專案] 對話框中輸入的名稱自動重新命名項目 檔名稱。 TargetFileName如果您想要為以範本建立的項目檔提供替代檔名,請使用屬性。

範例

下列範例顯示適用於 Visual C# 應用程式之專案範本的中繼資料。

<VSTemplate Type="Project" Version="3.0.0"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>My template</Name>
        <Description>A basic starter kit</Description>
        <Icon>TemplateIcon.ico</Icon>
        <ProjectType>CSharp</ProjectType>
    </TemplateData>
    <TemplateContent>
        <Project File="MyStarterKit.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>

另請參閱