Using CustomParameter with Visual Studio Multi-Project Template

Full Disclosure: I am the creator of the below mentioned project.

I solved the issue of sharing information between project templates in a multi-project template be creating an IWizard implementation called GlobalParams. It makes the information from the solution template level available to the child templates that also run the wizard by prefixing ALL solution level parameters with the word global and adding it to the child parameters.

If you used GlobalParams with the above template and the user entered "Test Project", the following would be true:

  • InterfaceTemplate.vstemplate could access
    • $safeprojectname$ = Test_Project.Interface
    • $globalsafeprojectname$ = Test_Project
  • BusinessTemplate.vstemplate could access
    • $safeprojectname$ = Test_Project.Business
    • $globalsafeprojectname$ = Test_Project

The above is an example of the safe project name but all parameters from the solution template are passed to child template See the GlobalParams Documentation for more information.


Visual Studio 2013 Update 2 finally added a built-in way to do this with ProjectTemplateLink

The CopyParameters attribute will enable child access to all the variables of the parent template, with the prefix of ext_.

You don't even need CustomParameters for this. Change your ProjectTemplateLink to this:

<ProjectTemplateLink ProjectName="$safeprojectname$.Interface" CopyParameters="true">
  Interface\InterfaceTemplate.vstemplate
</ProjectTemplateLink>

And then you can achieve your goal in the child .csproj like so:

<ItemGroup>
  <ProjectReference Include="..\$ext_safeprojectname$.Business\$ext_safeprojectname$.Business.csproj">
    <Project>{E5511F75-5B9C-4816-B991-E09225661CF4}</Project>
    <Name>MyTemplate.Business</Name>
  </ProjectReference>
</ItemGroup>