Skip to content

Commit ddc5899

Browse files
authored
fix:can not set icon file when packaging windows exe (#246)
1 parent f9908fd commit ddc5899

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/flutter_app_packager/lib/src/makers/exe/make_exe_config.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class MakeExeConfig extends MakeConfig {
2424
json['locales'] != null ? List<String>.from(json['locales']) : null;
2525
if (locales == null || locales.isEmpty) locales = ['en'];
2626

27+
// use absolute path
28+
String iconfile = '';
29+
if (json['setup_icon_file'] != null) {
30+
String currentDirectory = Directory.current.path;
31+
iconfile = p.join(currentDirectory, json['setup_icon_file']);
32+
}
33+
2734
MakeExeConfig makeExeConfig = MakeExeConfig(
2835
scriptTemplate: json['script_template'],
2936
appId: json['app_id'] ?? json['appId'],
@@ -34,7 +41,7 @@ class MakeExeConfig extends MakeConfig {
3441
createDesktopIcon: json['create_desktop_icon'],
3542
launchAtStartup: json['launch_at_startup'],
3643
installDirName: json['install_dir_name'],
37-
setupIconFile: json['setup_icon_file'],
44+
setupIconFile: iconfile,
3845
privilegesRequired: json['privileges_required'],
3946
locales: locales,
4047
);

website/src/content/docs/makers/exe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ display_name: Hello 世界
2020
create_desktop_icon: true
2121
# See: https://jrsoftware.org/ishelp/index.php?topic=setup_defaultdirname
2222
# install_dir_name: "D:\\HELLO-WORLD"
23+
# This path is relative to the root directory of your project; The format of icon file must be ico, can not be png or others
24+
# setup_icon_file: windows\runner\resources\app_icon.ico
2325
locales:
2426
- en
2527
- zh

website/src/content/docs/zh-hans/makers/exe.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ display_name: Hello 世界
2020
create_desktop_icon: true
2121
# See: https://jrsoftware.org/ishelp/index.php?topic=setup_defaultdirname
2222
# install_dir_name: "D:\\HELLO-WORLD"
23+
# 这里的路径是相对于项目根目录的路径; 图标格式必须是ico格式,不能是png或其它
24+
# setup_icon_file: windows\runner\resources\app_icon.ico
2325
locales:
2426
- en
2527
- zh

0 commit comments

Comments
 (0)