0

I have the following build pipeline task:

  - task: NuGetCommand@2
    displayName: 'Pack CodingStyles.nuspec'
    inputs:
      command: 'pack'
      packagesToPack: 'src\CodingStyles\CodingStyles.nuspec'
      packDestination: 'src\CodingStyles\bin'
      versioningScheme: 'off'
      buildProperties: '-NoDefaultExcludes -Version $(Build_Major).$(Build_Minor).$(Build_Patch)'

However, if the variable $IsPreRelease is true, I want to add another build property as well:

buildProperties: '-NoDefaultExcludes -Version $(Build_Major).$(Build_Minor).$(Build_Patch) -Suffix beta'

A few thoughts on how to do this:

  1. I could have two different versions of this task, each with a condition: based on the variable. This would probably work, but it's quite redundant since everything else is the same.
  2. Run a Powershell task instead of the NuGetCommand task, and build my command line dynamically.

Any options I'm missing?

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
Mike Christensen
  • 88,082
  • 50
  • 208
  • 326

1 Answers1

2

You are missing one option:

  - task: NuGetCommand@2
    displayName: 'Pack CodingStyles.nuspec'
    inputs:
      command: 'pack'
      packagesToPack: 'src\CodingStyles\CodingStyles.nuspec'
      packDestination: 'src\CodingStyles\bin'
      versioningScheme: 'off'
      ${{ if ne(variables['IsPreRelease'], 'true') }}:
        buildProperties: '-NoDefaultExcludes -Version $(Build_Major).$(Build_Minor).$(Build_Patch)'
      ${{ if eq(variables['IsPreRelease'], 'true') }}:
        buildProperties: '-NoDefaultExcludes -Version $(Build_Major).$(Build_Minor).$(Build_Patch) -Suffix beta'

enter image description here

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107