I am building a template in Visual Studio. The template is made of 3 C# projects. The names of the projects are as follows: name of the solution I create from my template followed by .Project1/.Project2/.Project3. For example, if I call the solution created from my template SolutionProject, the names of the projects would be: SolutionProject.Project1/.Project2/.Project3, respectively for the 3 projects. I do this with the following macro in my .vstemplate:
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$.Project1">Project1\MyTemplate.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Project2">Project2\MyTemplate.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Project3">Project3\MyTemplate.vstemplate</ProjectTemplateLink>
</ProjectCollection>
To fix the references, which were causing issues, I used the following macro in the .csproj for each proyect. For example, for Project3, which references Project2, I used:
<ItemGroup>
<ProjectReference Include="..\$(ProjectName.Replace('.Project3', '')).Project2\$(ProjectName.Replace('.Project3', '')).Project2.csproj">
<Project>{GUID}</Project>
<Name>$(ProjectName.Replace('.Project3', '')).Project2</Name>
</ProjectReference>
Otherwise, the reference would be SolutionProject.Project3.Project2 instead of the desired SolutionProject.Project2.
Lastly, I have to change the using statements in my C# files. One way I have been trying to do this, is using the $safeprojectname$ macro in the .cs files, and the macro seems to work. However, I have a similar problem to the one i had with the references. If I use $safeprojectname$.Project2 macro in a .cs file in the SolutionProject.Project3 project, this is transformed to using SolutionProject.Project3.Proejct2; Note that SolutionProject is a general name and it could take any value, it adopts the name you give the project built with the template. The solution I included above that I used with the references does not work and I am running out of ideas.