5

I have a multi-project solution template. I've created it using this guide.

My solution is generating multi-platform projects with a central shared project:

  • MyProject.Shared
  • MyProject.UWP
  • MyProject.Droid
  • etc.

The problem is that when I use $safeprojectname$.Shared in the csproj file of the individual projects (let's say in the UWP one) in order to add a reference to the shared project, what gets generated is MyProject1.UWP.Shared instead of MyProject1.Shared.

How do I refer to the shared project name / solution name from the individual projects?

P.S. There is the $SpecificSolutionName$ parameter, but that only works if the user checked the Create solution directory option, not good enough for me.

TL;DR

How do I get partial project name from parameter?

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632

2 Answers2

1

$ext_safeprojectname$ does the trick.

(credit)

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
1

In the root .vstemplate file you should use ProjectName="$projectname$" in ProjectTemplateLink tag:

<TemplateContent>
    <ProjectCollection>
      <ProjectTemplateLink ProjectName="$projectname$.Shared" CopyParameters="true">
        MyProject.Shared\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="$projectname$.UWP" CopyParameters="true">
        MyProject.UWP\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="$projectname$.Droid" CopyParameters="true">
        MyProject.Droid\MyTemplate.vstemplate
      </ProjectTemplateLink>
    </ProjectCollection>
  </TemplateContent>
Mahdi Ataollahi
  • 4,544
  • 4
  • 30
  • 38