0

I have two tasks:

enter image description here

The 'Set Solution Name does this:

$SolutionName = "UnknownSolution"
Write-Host "::vso[task.setvariable variable=SolutionName;]$SolutionName"
Write-Host "Solution Name: $SolutionName"

Here is the output of this task:

::vso[task.setvariable variable=SolutionName;]UnknownSolution Solution Name: UnknownSolution

The 'Get Solution Name' does this:

$SolutionNameFromTask = "$(SolutionName)"
Write-Host "Solution Name: $SolutionNameFromTask"

Error from this task:

SolutionName : The term 'SolutionName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\a_temp\8d389e74-a705-4c90-96cb-b36de82d0e87.ps1:5 char:28

  • $SolutionNameFromTask = "$(SolutionName)"
  •                        ~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (SolutionName:String) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : CommandNotFoundException

The 'Get Solution Name' can't find the "$(SolutionName)" and throws an error. My 'Set Solution Name' must not be creating a variable that can be seen by subsequent tasks. Is this not possible?

1 Answer 1

0

Silly mistake. The issue is on this line:

Write-Host "::vso[task.setvariable variable=SolutionName;]$SolutionName"

Which should be:

Write-Host "##vso[task.setvariable variable=SolutionName;]$SolutionName"

Not sure why I was using colons...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.