Unverified Commit eaf3f8b4 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Add VERSIONINFO to the Windows template (#66025)

Adds a VERSIONINFO to Runner.rc in the Windows app template, populated
from the project creation metadata.

Currently the version itself is hard-coded, but it is future-proofed to
allow plumbing the actual version through at build time via preprocessor
defines.
parent 580a96f9
......@@ -54,6 +54,57 @@ END
// remains consistent on all systems.
IDI_APP_ICON ICON "resources\\app_icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#else
#define VERSION_AS_NUMBER 1,0,0
#endif
#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#else
#define VERSION_AS_STRING "1.0.0"
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_AS_NUMBER
PRODUCTVERSION VERSION_AS_NUMBER
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "{{organization}}" "\0"
VALUE "FileDescription", "{{description}}" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "{{projectName}}" "\0"
VALUE "LegalCopyright", "Copyright (C) {{year}} {{organization}}. All rights reserved." "\0"
VALUE "OriginalFilename", "{{projectName}}.exe" "\0"
VALUE "ProductName", "{{projectName}}" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
......
......@@ -130,7 +130,7 @@
"templates/app/windows.tmpl/runner/resource.h",
"templates/app/windows.tmpl/runner/resources/app_icon.ico.img.tmpl",
"templates/app/windows.tmpl/runner/runner.exe.manifest",
"templates/app/windows.tmpl/runner/Runner.rc",
"templates/app/windows.tmpl/runner/Runner.rc.tmpl",
"templates/app/windows.tmpl/runner/run_loop.cpp",
"templates/app/windows.tmpl/runner/run_loop.h",
"templates/app/windows.tmpl/runner/utils.cpp",
......
......@@ -811,6 +811,25 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('Windows has correct VERSIONINFO', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--org', 'com.foo.bar', projectDir.path]);
final File resourceFile = projectDir.childDirectory('windows').childDirectory('runner').childFile('Runner.rc');
expect(resourceFile.existsSync(), true);
final String contents = resourceFile.readAsStringSync();
expect(contents, contains('"CompanyName", "com.foo.bar"'));
expect(contents, contains('"ProductName", "flutter_project"'));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
});
testUsingContext('app does not include Windows by default', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment