4

I had created auto deployment steps using TFS vNext build system. In one step I needs to access $(Date:yyyyMMdd) for some file versioning stuff.

Below you can find configuration and error snippet:

Configuration for power shell script step

Error while queuing build

So any idea how to access date related variables as argument in PowerShell script step ?

2
  • 2
    Hi, do you expect the to have current date in $(Date:yyyyMMdd) ? You could use $(Get-Date -f yyyyMMdd). Commented Jun 27, 2016 at 7:55
  • I need to pass it as param from Build PowerShellScript step, is it gonna work ? Commented Jun 27, 2016 at 8:04

2 Answers 2

8

"$(Date:yyyyMMdd)" is a token for Build number format, not a variable. So you cannot use it in the build steps.

The alternative way to do this is to set the "Build number format" under "General" tab to "$(Date:yyyyMMdd)", the variable "$(Build.BuildNumber)" will be filled with the value of "$(Date:yyyyMMdd)". And then you can use "$(Build.BuildNumber)" variable in the build steps.

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

2 Comments

This clue helped, i had create one extra step to modify a custom variable which will set to (Get-Date).ToString('yyyyMMddHHss') and pass that variable in consecutive steps.
Today in VTST, "General Tab" doesn't exist, the correct tab is "Options", and then, edit the "Build number format" input text field.
0

As the error tells you, date is not a function. You could set the -fileName parameter in your CompressFile script to:

Param(
    [string]$fileName = 'Package{0}' -f (Get-Date).ToString('yyyyMMdd')
)

And omit the parameter in the TFS VNext argument list (you can still overwrite it).

2 Comments

Make sense but i can't use it in this way, as this file is shared across multiple projects packaging and every single one of them have different prefix.
Then omit the date postfix when you invoke the script and append it within the CompressFile script...

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.