dart-lang / build

A build system for Dart written in Dart
https://pub.dev/packages/build
BSD 3-Clause "New" or "Revised" License
791 stars 211 forks source link

How can i generate .g.dart, .freezed.dart file during my CI/CD for release? #3725

Closed tangogithub321 closed 4 months ago

tangogithub321 commented 4 months ago

I'm using build_runner to generate some code in my project in a dev environment, but I want to use the latest generated file every time I package it, but during the CI/CD process, I get a message that pub doesn't recognize the ‘build_runner’ commands, and I know that the fvm flutter pub get precedes the fvm flutter pub run build_runner build execute. If I don't version .g.dart, .freezed.dart files, how do I generate the original files I need to use during CI/CD? Is it not a best practice to not version .g.dart, .freezed.dart files?

jakemac53 commented 4 months ago

It should work fine to run the commands as you have listed. I would need more information to try and diagnose why that isn't working.

Are you sure the package where you are running the commands from has a dependency on build_runner?

tangogithub321 commented 4 months ago

Hi, Thanks for your help, I have solved it. I made a low-level mistake. In the taskfile, I entered fvm flutter pub build_runner build, missing the run, which caused the error. This is my issue. I will close this issue.