简体   繁体   中英

TFS build powershell script step : Not able to access $(Date:yyyyMMdd) variable

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:

配置电源shell脚本步骤

排队构建时出错

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

"$(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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM