I had a comment left on my last post about enterprise templates, and it is a good time to discuss a new feature in our VSTemplate Wizard – Multi-Project Templates. The most common way of using the VSTemplate Wizard is to create a single project or project item. However, there may be times when you need to build an entire solution, with multiple projects that work together. And you can do that with Multi-Project Templates.
Suppose you need to build a solution with a WinForm project, a Web Service, and a Class Library, all within the same solution. With Visual Studio 2003, you need to add three separate projects to your solution, then write the code to wire the three projects together. To create a VS Template that wires the three of these together, you would first manually create the solution with these three projects, and wire up the code the way you want them to work. Then, one by one, use the Export Template tool to export the templates. Next, you would create a fourth template that links the three projects together, with an XML .vstemplate that looks much like this (I am writing this from home without the exact XML in front of me, so the exact XML may be a bit different):
The Template Wizard will first create a solution if the user selects to create a new solution, or will add the projects to the existing solution if the user so chooses, then walk through the XML and recursively call the Template Wizard to add each sub-project to the solution. Since you exported projects that all worked together when you first created the project, the WinForm project can call off to the Class Library, and call into the Web Service, which was installed into the correct place for use by a web server.
But you can also use Multi-Project Templates to organize your projects. Visual Studio supports what we are calling Solution Folders. These folders allow you to group projects together into folders. Just like you can create folders within a project to organize files, you can create folders within a solution to organize projects and files. You can construct XML in a Multi-Project Template to construct folders and organize projects. The XML for this looks like this:
<Folder Name=“UI Projects“>
<Folder Name=“Class Libraries“>
Not only can you use your own projects as sub-projects, but you can use a relative path to link to an existing project. For example, if you put your template in the correct location, you can link to existing project templates:
I also saw a comment saying that the images I uploaded from my last post were not showing. I uploaded them to a MSN Group, and it may be possible that the security settings were not set right, I will check into it and see what I can do