如何使用 Visual Studio 2017 创建项目组模板

How To Create Project Group Template Using Visual Studio 2017

解决办法下模板中文件夹没有出现

我用了link

中的方法

https://www.c-sharpcorner.com/article/how-to-create-multi-project-template-using-visual-studio-2017/?


<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Solution Template</Name>
    <Description>An example of a multi-project template</Description>
    <Icon>__TemplateIcon.ico</Icon>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>DomainKod.ModulKod</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <SolutionFolder Name="Src">
        <ProjectTemplateLink ProjectName="$projectname$.Api">
          DomainKod.ModulKod.Api\Api.vstemplate
        </ProjectTemplateLink>
        <ProjectTemplateLink ProjectName="$projectname$.Web">
          DomainKod.ModulKod.Web\Web.vstemplate
        </ProjectTemplateLink>
      </SolutionFolder>
      <SolutionFolder Name="Tests">
        <ProjectTemplateLink ProjectName="$projectname$.Web.Tests">
          DomainKod.ModulKod.Web.Tests\Web.Tests.vstemplate
        </ProjectTemplateLink>
      </SolutionFolder>
      <SolutionFolder Name="SolutionItems">
        <ProjectTemplateLink ProjectName="SolutionItems">
          SolutionItems\Solution.vstemplate
        </ProjectTemplateLink>
      </SolutionFolder>
    </ProjectCollection>
  </TemplateContent>
</VSTemplate>

SolutionItems.vstemplate

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>SolutionItems</Name>
    <Description>&lt;No description available&gt;</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <CreateInPlace>true</CreateInPlace>
    <DefaultName>SolutionDeneme</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.ico</Icon>
  </TemplateData>
  <TemplateContent>
      <Folder Name="App-Keys" TargetFolderName="App-Keys">
        <ProjectItem ReplaceParameters="true">key.xml</ProjectItem>
      </Folder>
  </TemplateContent>
</VSTemplate>

SolutionItems 文件夹不适合我的模板创建。 如何启用添加 SolutionItems 文件夹模板?

您可以为多项目模板创建向导。

https://docs.microsoft.com/en-us/visualstudio/extensibility/how-to-use-wizards-with-project-templates?view=vs-2019

Dotnet CLI 可以帮助您完成向导中无法执行的操作。

https://docs.microsoft.com/tr-tr/dotnet/core/tools/?tabs=netcore2x