0

I have a project template that contains a powershell script called BuildStandard.ps1. Inside that script is the following excerpt:

Invoke-psake -buildFile $psakeScript `
            -parameters @{
                "solutionFile" = Resolve-Path("..\$SpecificSolutionName$.sln")
            }

When a new project is added using the template, I want the $SpecificSolutionName$ parameter to be replaced with, well, the solution name. Only problem is that this content from the .vstemplate file isn't cutting it:

  <TemplateContent>
    <Project TargetFileName="PsakeInstallTestBench.csproj" File="PsakeInstallTestBench.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true">BuildStandard.ps1</ProjectItem>
    </Project>
  </TemplateContent>

What am I missing?

EDIT: I've verified that if I replace $SpecificSolutionName$ with $safeprojectname$, the parameter is replaced. I'm beginning to wonder if $SpecificSolutionName$ is available only for solution-level templates. Is there a workaround for this?

ket
  • 728
  • 7
  • 22
  • I think that you have to escape the $ with a back tick in your Resolve-Path call: Resolve-Path ..\`$SpecificSolutionName`$.sln Also note that I have removed the parentheses. – David Brabant Apr 29 '17 at 16:24
  • Tried it, but no dice: the line in the new project still shows up verbatim: Resolve-Path(..\`$SpecificSolutionName`$.sln). The backslash isn't playing a role here, is it? – ket May 01 '17 at 15:08
  • Yes, it is. My wrong: there should be a backslash. – David Brabant May 01 '17 at 15:18
  • Total SO confusion! I believe both you and I *had* a backslash included in our comments before the first backtick, but it looks like SO is filtering it out. In my .ps1 file, I do have the backslash included; I meant to inquire whether the presence of the backslash in the .ps1 file before the backtick might cause the $ to be escaped. – ket May 01 '17 at 15:47

0 Answers0