Search code examples
tfstfsbuilddotnet-cli

TFS : Add options from expression


In TFS 2018, I use the task build "dotnet pack". To generate a beta, I set the additional build properties to :

PackageVersion=2.0.$(Build.BuildNumber)-beta

To generate a release, I need remove "-beta" :

PackageVersion=2.0.$(Build.BuildNumber)

Is posible to add "-beta" from a expression? Like :

PackageVersion=2.0.$(Build.BuildNumber)$[ $(beta) ? "-beta" : "" ]

*$(beta) is a variable


Solution

  • I set the additional build properties :

    PackageVersion=2.0.$(Build.BuildNumber)$(beta)
    

    And the variable $(beta) has the default value "-beta". For build a beta, I don't modify $(beta) variable. Then the package version is "2.0.145-beta".

    For build a release, I remove the value in $(beta) variable. Then the package version is "2.0.146".