Skip to content

[Windows] support pubspec.yaml version/build number in windows projects #73652

@narumi147

Description

@narumi147

Steps to Reproduce

  1. flutter config --enable-windows-desktop
  2. create a new project and run flutter build windows, the built exe version should be 1.0.0.0
  3. change version in pubspec.yaml from 1.0.0+1 to any other version like 1.1.1+2
  4. pub get and build again, the version of exe is still 1.0.0.0
  5. flutter clean doesn't help

I have to change the default value of VERSION_AS_NUMBER and VERSION_AS_STRING in windows/runner/Runner.rc. However, these two value SHOULD be used only when FLUTTER_BUILD_NUMBER and FLUTTER_BUILD_NAME not defined, and they should be defined from version in pubspec.yaml when run pub get ?

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#else
#define VERSION_AS_NUMBER 1,1,1,2
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#else
#define VERSION_AS_STRING "1.1.1.2"
#endif
flutter doctor -v
[✓] Flutter (Channel master, 1.26.0-2.0.pre.167, on Microsoft Windows [Version 10.0.19042.685], locale zh-CN)
    • Flutter version 1.26.0-2.0.pre.167 at D:\Projects\sdk\flutter
    • Framework revision d3a2259541 (9 days ago), 2020-12-31 15:14:03 -0500
    • Engine revision 82b4ae86d6
    • Dart version 2.12.0 (build 2.12.0-179.0.dev)
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\Projects\sdk\Android\Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = D:\Projects\sdk\Android\Sdk
    • Java binary at: C:\Users\narumi\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\201.6953283\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.8.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
    • Visual Studio Enterprise 2019 version 16.8.30804.86
    • Windows 10 SDK version 10.0.18362.0

[✓] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\narumi\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\201.6953283
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] VS Code (version 1.52.1)
    • VS Code at C:\Users\narumi\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19042.685]
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 87.0.664.75

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: buildBuilding flutter applications with the toola: desktopRunning on desktopc: new featureNothing broken; request for a new capabilityplatform-windowsBuilding on or for Windows specificallytoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions