mahars
mahars

Reputation: 41

VS Multi Project template creates an extra folder when creating new project

I Created a Multi-Project custom template. Here is my folder structure after I Exported the Template.

ServiceTemplate
 |_Template.Service
  |_MyTemplate.vstemplate
 |_Template.Service.Interface
  |_MyTemplate.vstemplate
 |_root.vstemplate

I zipped all files and folders under "ServiceTemplate" which Gave me "ServiceTemplate.zip"

I copied that zip file under "Visual Studio 2017\Templates\ProjectTemplates"

I went to visual studio and created a new project (Test.Service) from my Template and solution (TestService).

I ticked "Create solution folder" when creating a new project but didn't work

I added false in root.vstemplate but didn't work

<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">  
  <TemplateData>  
    <Name>Service Template</Name>  
    <Description></Description>  
    <ProjectType>CSharp</ProjectType> 
    <CreateNewFolder>false</CreateNewFolder>  
  </TemplateData>  
  <TemplateContent>  
    <ProjectCollection>  
      <ProjectTemplateLink ProjectName="$safeprojectname$" CopyParameters="true">  
          Template.Service\MyTemplate.vstemplate  
        </ProjectTemplateLink>

        <ProjectTemplateLink ProjectName="$safeprojectname$.Interface" CopyParameters="true">  
          Template.Service.Interface\MyTemplate.vstemplate  
        </ProjectTemplateLink>  
    </ProjectCollection>  
  </TemplateContent>  
</VSTemplate> 

Expected

TestService
 |_packages
 |_TestService.sln
 |_Test.Service
  |_Test.Service.csproj
 |_Test.Service.Interface
  |_Test.Service.Interface.csproj

Actual

TestService
 |_packages
 |_TestService.sln
 |_TestService <--- (un-necessary folder)
  |_Test.Service
   |_Test.Service.csproj
  |_Test.Service.Interface
   |_Test.Service.Interface.csproj

Upvotes: 3

Views: 730

Answers (1)

billy bud
billy bud

Reputation: 121

I had the same issue but was using vs2022 and dotnet new templates. My solution was to tick "Place solution and project in the same directory" I always ignored this checkbox as I have multiple projects and never want solution files in the same directory, but the option is misleading. When I tick that box all that happens is the extra folder is gone.

Upvotes: 2

Related Questions