12

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!

Ceottaki
  • 694
  • 1
  • 9
  • 17
  • Possible duplicate of [Issue with visual studio template & directory creation](http://stackoverflow.com/questions/3882764/issue-with-visual-studio-template-directory-creation) – Chamika Sandamal Jul 03 '16 at 16:44

2 Answers2

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...

Community
  • 1
  • 1
geoid
  • 285
  • 3
  • 8
  • 1
    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... – Ceottaki Jul 04 '13 at 13:18
  • 1
    Agreed, it seems like a total hack to have to resort to the wizard for that. – geoid Jul 04 '13 at 14:11
  • I wonder if this is fixed in VS2013, it certainly isn't in VS2012. – tofutim Dec 10 '13 at 23:34
  • 1
    Same problem with Visual Studio 2013 and no idea how to fix it. Any idea, maybe? – boj Mar 03 '14 at 00:08
  • For @boj and anyone else who stumbles across this in a google search like I did, VS2013 fixed this issue. See [this answer](http://stackoverflow.com/a/24043435/4416750). If, like me, you are on a VS version that is earlier than specified in that answer, it seems we are out of luck. :( – Lews Therin Jul 19 '16 at 18:27
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.

Dbl
  • 5,634
  • 3
  • 41
  • 66