Weird folder hierarchy when creating multi-project Visual Studio template
Asked Answered
W

2

13

I am manually creating a multi-project template for Visual Studio 2012 and I followed the guidelines from this page: http://msdn.microsoft.com/en-us/library/ms185308.aspx

The problem I am having is that a weird folder structure is created with this template that is not what I would normally expect. The folder structure I am getting for a solution called SolutionName:

[SolutionName]
     |
     \--- SolutionName.sln
     |
     \--- [SolutionName]
               |
               \--- Project1
               |       |
               |       \--- Project1.csproj
               \--- Project2
                       |
                       \--- Project2.csproj

Now, what I would normally expect would've been this:

[SolutionName]
     |
     \--- SolutionName.sln
     |
     \--- Project1
     |       |
     |       \--- Project1.csproj
     \--- Project2
             |
             \--- Project2.csproj

Is there any way to achieve the second folder structure?

Also, when specifying solution folders in the template, they're also being created as real folders, is there any way to avoid that?

This is how my multi-project vstemplate file looks:

<?xml version="1.0"?>
<VSTemplate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Type="ProjectGroup" Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>My Multi-Solution Template</Name>
    <Description>No Description.</Description>
    <Icon>__TemplateIcon.png</Icon>
    <PreviewImage>__PreviewImage.png</PreviewImage>
    <ProjectType>CSharp</ProjectType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder> <!-- No use in trying false here. -->
    <DefaultName>SolutionName</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <LocationField>Enabled</LocationField>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <SolutionFolder Name="Application">
    <SolutionFolder Name="Tests">
      <ProjectTemplateLink ProjectName="$safeprojectname$.UnitTests">UnitTests\UnitTests.vstemplate</ProjectTemplateLink>
    </SolutionFolder>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Core">Core\Core.vstemplate</ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Infrastructure">Infrastructure\Infrastructure.vstemplate</ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.Model">Model\Model.vstemplate</ProjectTemplateLink>
      </SolutionFolder>
      <SolutionFolder Name="Service">
    <ProjectTemplateLink ProjectName="$safeprojectname$.ServiceHost">ServiceHost\ServiceHost.vstemplate</ProjectTemplateLink>
    <ProjectTemplateLink ProjectName="$safeprojectname$.ServiceLibrary">ServiceLibrary\ServiceLibrary.vstemplate</ProjectTemplateLink>
      </SolutionFolder>
    </ProjectCollection>
    <CustomParameters />
  </TemplateContent>
</VSTemplate>

Thanks!

Wolves answered 27/6, 2013 at 11:4 Comment(1)
Possible duplicate of Issue with visual studio template & directory creationMilicent
M
0

I'm having the exact same problem. I've found this similar question with a suggestion of using nested templates and a wizard, am just about to try it out...

Maisonette answered 2/7, 2013 at 9:21 Comment(5)
Hi, geoid, I actually know how to do that using the wizard DLL and just moving everything to the right folders but it didn't seem right to do that, I much rather have something in the vstemplate that I could configure to do that from the start...Wolves
Agreed, it seems like a total hack to have to resort to the wizard for that.Maisonette
I wonder if this is fixed in VS2013, it certainly isn't in VS2012.Burkhardt
Same problem with Visual Studio 2013 and no idea how to fix it. Any idea, maybe?Dan
For @Dan and anyone else who stumbles across this in a google search like I did, VS2013 fixed this issue. See this answer. If, like me, you are on a VS version that is earlier than specified in that answer, it seems we are out of luck. :(Daedal
M
0

Check here for additional information on this topic. Perhaps the docs team will document this at some point.

You can also install Amusoft tooling from the VS Marketplace to move folders now. It'll update solution and inter project references too.

Mede answered 25/9, 2019 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.