I am trying to write a very easy inline script which should update the variable NameSuffix to a new value. I wanted to use a local helper variable newVar.
Write-Host "Detected version: $(AssemblyInfo.AssemblyVersion)";
$newVar = "v$(AssemblyInfo.AssemblyVersion.Major).$(AssemblyInfo.AssemblyVersion.Minor).$(AssemblyInfo.AssemblyVersion.Build).$(AssemblyInfo.AssemblyVersion.Release)";
Write-Output ("##vso[task.setvariable variable=NameSuffix;]$(newVar)");
But Visual Studio Online / VSTS tells me when the scrips runs:
The term 'newVar' 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.
Using a variable this way seems common in script files and works on the command line.
So how can I accomplish this simple assignment of a variable (with a concated value) as a build task in VSO/VSTS?
$($newVar)
? – t0mm13b$($newVar)
and also with$newVar
in the 3rd line as demonstrated in the accepted answer. – ZoolWay