Skip to content

[web] Add --build-name and --build-number flags to flutter build web #75909

@krisleland

Description

@krisleland

The version.json file that gets created with 'flutter build web' seems to be the intended way to get versioning information in the flutter web environment. I want to be able to change the version.json file with flags --build-name and --build-number so that I can change that file from a hosted service.

Proposal

Like ios and android, add --build-name and --build-number flags to web build to allow a hosted service to manage versioning.


Build a web application bundle.

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands executed.
                            If used with --help, shows hidden options.
-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.

Usage: flutter build web [arguments]
-h, --help                           Print this usage information.
    --[no-]tree-shake-icons          Tree shake icon fonts so that only glyphs used by the application remain.
-t, --target=<path>                  The main entry-point file of the application, as run on the device.
                                     If the --target option is omitted, but a file name is provided on the command line, then that is used instead.
                                     (defaults to "lib\main.dart")
    --[no-]pub                       Whether to run "flutter pub get" before executing this command.
                                     (defaults to on)
    --profile                        Build a version of your app specialized for performance profiling.
    --release                        Build a release version of your app (default mode).
    --dart-define=<foo=bar>          Additional key-value pairs that will be available as constants from the String.fromEnvironment, bool.fromEnvironment,
                                     int.fromEnvironment, and double.fromEnvironment constructors.
                                     Multiple defines can be passed by repeating --dart-define multiple times.
    --web-renderer                   The renderer implementation to use when building for the web. Possible values are:
                                     html - always use the HTML renderer. This renderer uses a combination of HTML, CSS, SVG, 2D Canvas, and WebGL. This is the default.
                                     canvaskit - always use the CanvasKit renderer. This renderer uses WebGL and WebAssembly to render graphics.
                                     auto - use the HTML renderer on mobile devices, and CanvasKit on desktop devices.
                                     [auto (default), canvaskit, html]
    --[no-]null-assertions           Perform additional null assertions on the boundaries of migrated and un-migrated code. This setting is not currently supported on
                                     desktop devices.
    --[no-]native-null-assertions    Enables additional runtime null checks in web applications to ensure the correct nullability of native (such as in dart:html) and
                                     external (such as with JS interop) types. This is enabled by default but only takes effect in sound mode. To report an issue with a null
                                     assertion failure in dart:html or the other dart web libraries, please file a bug at
                                     https://github.com/dart-lang/sdk/issues/labels/web-libraries .
                                     (defaults to on)
    --csp                            Disable dynamic generation of code in the generated output. This is necessary to satisfy CSP restrictions (see
                                     http://www.w3.org/TR/CSP/).
    --[no-]source-maps               Whether to generate a sourcemap file. These can be used by browsers To view and debug the original source code of a compiled and
                                     minified Dart application. Defaults to false (i.e. no sourcemaps produced).
    --pwa-strategy                   The caching strategy to be used by the PWA service worker.
                                     offline-first will attempt to cache the app shell eagerly and then lazily cache all subsequent assets as they are loaded. When making a
                                     network request for an asset, the offline cache will be preferred.
                                     none will generate a service worker with no body. This is useful for local testing or in cases where the service worker caching
                                     functionality is not desirable
                                     [offline-first (default), none]```
                                     
ios:

Build an iOS application bundle (Mac OS X host only).

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands executed.
                            If used with --help, shows hidden options.
-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.

Usage: flutter build ios [arguments]
-h, --help                          Print this usage information.
    --[no-]tree-shake-icons         Tree shake icon fonts so that only glyphs used by the application remain.
                                    (defaults to on)
    --split-debug-info=<v1.2.3/>    In a release build, this flag reduces application size by storing Dart program symbols in a separate file on the host rather than in the
                                    application. The value of the flag should be a directory where program symbol files can be stored for later use. These symbol files
                                    contain the information needed to symbolize Dart stack traces. For an app built with this flag, the 'flutter symbolize' command with the
                                    right program symbol file is required to obtain a human readable stack trace.
                                    This flag cannot be combined with --analyze-size
    --debug                         Build a debug version of your app.
    --profile                       Build a version of your app specialized for performance profiling.
    --release                       Build a release version of your app (default mode).
-t, --target=<path>                 The main entry-point file of the application, as run on the device.
                                    If the --target option is omitted, but a file name is provided on the command line, then that is used instead.
                                    (defaults to "lib\main.dart")
    --flavor                        Build a custom app flavor as defined by platform-specific build setup.
                                    Supports the use of product flavors in Android Gradle scripts, and the use of custom Xcode schemes.
    --[no-]pub                      Whether to run "flutter pub get" before executing this command.
                                    (defaults to on)
    --build-number                  An identifier used as an internal version number.
                                    Each build must have a unique identifier to differentiate it from previous builds.
                                    It is used to determine whether one build is more recent than another, with higher numbers indicating more recent build.
                                    On Android it is used as 'versionCode'.
                                    On Xcode builds it is used as 'CFBundleVersion'
    --build-name=<x.y.z>            A "x.y.z" string used as the version number shown to users.
                                    For each new version of your app, you will provide a version number to differentiate it from previous versions.
                                    On Android it is used as 'versionName'.
                                    On Xcode builds it is used as 'CFBundleShortVersionString'
    --[no-]obfuscate                In a release build, this flag removes identifiers and replaces them with randomized values for the purposes of source code obfuscation.
                                    This flag must always be combined with "--split-debug-info" option, the mapping between the values and the original identifiers is stored
                                    in the symbol map created in the specified directory. For an app built with this flag, the 'flutter symbolize' command with the right
                                    program symbol file is required to obtain a human readable stack trace.

                                    Because all identifiers are renamed, methods like Object.runtimeType, Type.toString, Enum.toString, Stacktrace.toString, Symbol.toString
                                    (for constant symbols or those generated by runtime system) will return obfuscated results. Any code or tests that rely on exact names
                                    will break.
    --dart-define=<foo=bar>         Additional key-value pairs that will be available as constants from the String.fromEnvironment, bool.fromEnvironment,
                                    int.fromEnvironment, and double.fromEnvironment constructors.
                                    Multiple defines can be passed by repeating --dart-define multiple times.
    --[no-]null-assertions          Perform additional null assertions on the boundaries of migrated and un-migrated code. This setting is not currently supported on desktop
                                    devices.
    --[no-]analyze-size             Whether to produce additional profile information for artifact output size. This flag is only supported on release builds. When building
                                    for Android, a single ABI must be specified at a time with the --target-platform flag. When building for iOS, only the symbols from the
                                    arm64 architecture are used to analyze code size.
                                    This flag cannot be combined with --split-debug-info.
    --[no-]config-only              Update the project configuration without performing a build. This can be used in CI/CD process that create an archive to avoid performing
                                    duplicate work.
    --[no-]simulator                Build for the iOS simulator instead of the device. This changes the default build mode to debug if otherwise unspecified.
    --[no-]codesign                 Codesign the application bundle (only available on device builds).
                                    (defaults to on)
                                    
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.27.0-2.0.pre.79, on Microsoft Windows [Version 10.0.18363.1316], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.6.0)
[√] Android Studio (version 4.0)
[√] IntelliJ IDEA Ultimate Edition (version 2020.1)
[√] Connected device (2 available)

• No issues found!


Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterplatform-webWeb applications specificallyteam-webOwned by Web platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions