plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[package_info_plus] Wrong version on windows

Open gutisalex opened this issue 2 years ago • 9 comments

Hey,

Steps to reproduce: I've set the version to 1.0.22+22 in pubspec yaml...

I use a function to get the version:

Future<String> getAppVersion() async {
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    return packageInfo.version;
  }

Result: On Android I am getting 1.0.2 On Windows I am getting 1.0.0

Expected: On Windows it should also be 1.0.2

gutisalex avatar Jul 05 '21 08:07 gutisalex

@jpnurmi do you have any idea for this?

mhadaily avatar Jul 06 '21 17:07 mhadaily

I recall it's the version of the .exe, which should be possible to define with CMake.

jpnurmi avatar Jul 06 '21 17:07 jpnurmi

I've set the version to 1.0.22+22 in pubspec yaml

This doesn't currently do anything for Windows builds; see https://github.com/flutter/flutter/issues/73652

stuartmorgan avatar Jul 10 '21 21:07 stuartmorgan

same issue, any solution?

sgsm74 avatar Dec 06 '21 11:12 sgsm74

Same here for windows

Eerey avatar Apr 12 '22 12:04 Eerey

Everyone will have this behavior on Windows because, per my comment above, that's how Flutter currently works. The version in pubspec.yaml has no impact on the Windows executable you get from flutter build, you have to change the version in Runner.rc.

stuartmorgan avatar Apr 12 '22 14:04 stuartmorgan

Is this the same reason for the version now? 1.4.2. Instead of the value 1.0.2 i get 1 only. no decimal. (in windows)

chitgoks avatar Apr 23 '22 02:04 chitgoks

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jun 23 '22 00:06 github-actions[bot]

The newest ones are already supported and can get the version number correctly

ismanong avatar Jul 26 '22 09:07 ismanong

I have a old windows project where this problem occur. Duplication the example project in package_info_plus works okay, but not my old project. This leads me to believe that I must update something in my project. What ???

lgLindstrom avatar Oct 13 '22 13:10 lgLindstrom

I have a old windows project where this problem occur. Duplication the example project in package_info_plus works okay, but not my old project. This leads me to believe that I must update something in my project. What ???

Here is the migration guide for you.

Flutter 3.3 added support for setting the Windows app’s version from the pubspec.yaml file or through the --build-name and --build-number build arguments. For more information, refer to the Build and release a Windows app documentation.

Projects created before Flutter version 3.3 need to be migrated to support versioning.

he0119 avatar Oct 13 '22 13:10 he0119

IMHO, and after few test, the problem IS NOT an issue of thi package [package_info_plus] , but the COMPILER used by Flutter.

If you see the details of the .exe with "Windows Explorer", you will see the same number that the [package_info_plus] return. image image

If you search you will found a lot of thread about the version of Flutter-Windows app and all talk about a runnner.rc

neoDD69 avatar Dec 22 '22 17:12 neoDD69

This is fixed now that https://github.com/flutter/flutter/issues/73652 has been fixed, but you'll need to migrate your project by following the instructions here for projects created before Flutter 3.3

Levi-Lesches avatar Mar 14 '23 03:03 Levi-Lesches

I was about to leave an issue.. but I also had the same problem. If you had started a project before Flutter 3.3, then your Windows build will be "stale" and not work with this package "as expected" Getting the version and build from the yaml. You will be saying "It works in Android, but not in Windows." It would be good to document this issue in the package info readme to tell people to upgrade the windows build..

To solve this problem Delete the windows directory of your project and do the flutter create again. flutter create --platforms=windows .

You can see this link here https://docs.flutter.dev/platform-integration/windows/version-migration

After doing this, you will then be able to get the desired results.

In any case.. I appreciate this package very much and we ship to 5 Os's. We have a project that was started a while back and had trouble with determining version numbers because we hardcoded it.. and we are lazy to change every time. However, the build number increments are required for app store submission, so we cannot be lazy with that.

It might just be that older projects that started the flutter create with windows only one year ago will be looking for this package_info addon as a solution, yet encounter these same errors. I also suggest a way to place issues a little easier. I did a few things and then realized I would have to compile the example program first.. so I lost my writing and gave up. Compiling the given example program would probably still give me an error, because I often have a project used for compiling sample programs. And if my stub was old enough, that would be an older windows setup.

bksubhuti avatar May 21 '23 05:05 bksubhuti

@bksubhuti Thank you very much for such detailed feedback. I will update the documentation to explicitly mention requirement to migrate.

vbuberen avatar Aug 05 '23 10:08 vbuberen