I am trying to create a multi project template. I wish the sub projects names to contain the solution name. I have tried the following however $safeprojectName$ doesn't work in the root template for some reason. It tries to create the folders with $safeprojectName$ in the name rather than the actual project name.
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Default Solution</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<SolutionFolder Name="$safeprojectName$.Web">
<ProjectTemplateLink ProjectName="$safeprojectName$.Web">
Src\Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
I have done a lot of reading on this and have and have created an assembly using the IWizard interface that creates a parameter $solutionName$. I then used the following template.
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Default Solution</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<SolutionFolder Name="$solutionName$.Web">
<ProjectTemplateLink ProjectName="$solutionName$.Web">
Src\Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
<WizardExtension>
<Assembly>DefaultSoloutionWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f753ddb61a28cb36, processorArchitecture=MSIL</Assembly>
<FullClassName>DefaultSoloutionWizard.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
This however also fails with the same problem. I'm I trying to do the impossible? Any help on this would be most welcome.
As of Visual Studio 2013 Update 2 you can now use the CopyParameters attribute on the ProjectTemplateLink element in the root .vstemplate file. Any parameters defined in the root template will be available in the linked templates with a "ext_" prefix.
For example, if the root template defines a parameter, $Foo$, then the parameter $ext_Foo$ will be available in the linked projects with the same value.
See http://msdn.microsoft.com/en-us/library/ms171398.aspx for more detail.
You may want to look into the Guidance Automation Toolkit. There's a fair amount to digest there, but part of what it can do is put a Wizard-based UI on a multi-project template.
If you want to see an example of that, take a look at the Service Factory, which can create an entire solution structure based in part on a wizard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With