Shimmy Weitzhandler
Shimmy Weitzhandler

Reputation: 104692

VS template parameters: Get partial project name

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:

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?

Upvotes: 5

Views: 1264

Answers (2)

Mahdi Ataollahi
Mahdi Ataollahi

Reputation: 5202

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>

Upvotes: 1

Shimmy Weitzhandler
Shimmy Weitzhandler

Reputation: 104692

$ext_safeprojectname$ does the trick.

(credit)

Upvotes: 1

Related Questions