I have a multi-project template that is working for the most part.
I am able to generate both projects and their files (named correctly), but one of my projects requires references to the other. I am attempting to have the template fill in these references correctly, but am having issues.
Here is my master (solution) template file:
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Template</Name>
<Description>Template (includes web and core)</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$.Web">
Template.Project.Web\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Core">
Template.Project.Core\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Now inside the ".Web" project, I often say using x.Core;
, but if I do $safreprojectname$.Core
the line ends up being x.Web.Core
. It seems that once each project is being generated, the $safreprojectname$
variable is changed to the current project. Which makes sense. But is there a way to either get the solution name or perhaps the name of other projects? I tried setting a variable in the solution file, but it does not seem to be passed to the project files.
Anyone have a suggestion?
Edit: in addition to the helpful answer below, here is a blog that I wrote after I finished this process. It links to a bunch of articles that I found to be very helpful: https://thebhwgroup.com/blog/2013/10/visual-studio-templates
I ended up solving this problem with the use of a wizard as shown in the following example: http://blog.tonysneed.com/2011/09/14/build-a-multi-project-visual-studio-template/
In addition to the blog above, check out the top comment below for VS 2013. I also wrote a quick blog that helps with older versions of VS: https://thebhwgroup.com/blog/2013/10/visual-studio-templates