hey24sheep / azure-flutter-tasks

Easily build and deploy with latest Flutter build tasks for Azure DevOps Pipelines Tasks
https://marketplace.visualstudio.com/items?itemName=Hey24sheep.flutter
MIT License
89 stars 22 forks source link

Variable `FlutterPubCachePath` provides an empty directory #99

Closed Zazo032 closed 5 months ago

Zazo032 commented 1 year ago

Pipeline:

  - task: Cache@2
    displayName: 'Cache Flutter'
    inputs:
      cacheHitVar: FLUTTER_CACHED
      key: 'flutter | stable | $(Agent.OS)'
      path: $(Agent.ToolsDirectory)/flutter

  - task: FlutterEnv@0
    condition: eq(variables.FLUTTER_CACHED, 'true')
    displayName: 'Setup Flutter'
    inputs:
      customPath: '$(Agent.ToolsDirectory)/flutter'
      pathType: 'customPath'

  - task: FlutterInstall@0
    condition: eq(variables.FLUTTER_CACHED, 'false')
    displayName: 'Install Flutter'
    inputs:
      channel: 'stable'
      mode: 'auto'
      version: 'latest'

  - task: CmdLine@2
    displayName: 'Dart: Pub get'
    inputs:
      failOnStderr: true
      script: 'dart pub get'

  - task: CmdLine@2
    displayName: 'Pub cache path (task)'
    inputs:
      script: 'echo $(FlutterPubCachePath)'

  - task: CmdLine@2
    displayName: 'Pub cache files (task)'
    inputs:
      script: 'ls -a $(FlutterPubCachePath)'

The output of Pub cache path (task):

/opt/hostedtoolcache/flutter/.pub-cache

The output of Pub cache files (task):

ls: cannot access '/opt/hostedtoolcache/flutter/.pub-cache': No such file or directory
##[error]Bash exited with code '2'.

Seems like the returned path from FlutterPubCachePath is wrong or dart pub get is not saving the packages in that directory

hey24sheep commented 1 year ago

Hi, the issue is on latest versions of Flutter (that directory doesn't exists)

You can use these two already available commands

Both of these paths provide you with pub commands so you don't need the FlutterPubCachePath. This isn't an issue from this extension but how the Flutter evolved and upgraded over the years.

Close this issue once you verify the above solution.