buildInnoSetupScript method
Builds an Inno Setup script and saves it to a file.
The file will be saved in the BuildMode.installerPath directory and will
have the name setup_script.iss
.
Implementation
Future<File> buildInnoSetupScript() async {
final generator = IssGenerator(
appId: Config.appId!,
appName: Config.appName!,
appVersion: Config.appVersion!,
defaultDirname: '${Inno.autopf}\\${Config.appName}',
defaultLanguages: Language.english,
);
generator
..addSetup(
key: 'OutputDir',
value: mode.installerPath,
)
..addSetup(
key: 'OutputBaseFilename',
value: 'installer',
)
..addSetup(
key: 'MinVersion',
value: '10.0.10240',
)
..addFiles(
source: '${mode.buildPath}\\*',
flags: [FileFlag.recurseSubdirs, FileFlag.createAllSubdirs],
)
// ..addFiles(
// source: vcRedistPath,
// destination: '${Inno.tmp}',
// )
..addRun(
fileName: '${Inno.autopf}\\${Config.appName}\\${Config.execName}',
flags: [RunFlag.postInstall, RunFlag.skipIfSilent],
description: '{cm:LaunchProgram,${Config.appName}}',
)
// ..addRun(
// fileName: '${Inno.tmp}\\$vcRedistExe',
// parameters: '/install /passive /norestart',
// flags: [RunFlag.runHidden],
// message: 'Installing Microsoft Visual C++ 2015-2022 Redistributable...',
// )
..addIcons(
name: '${Inno.autoprograms}\\${Config.appName}',
fileName: '${Inno.app}\\${Config.bundleId}.exe',
)
..addIcons(
name: '${Inno.autodesktop}\\${Config.appName}',
fileName: '${Inno.app}\\${Config.bundleId}',
tasks: ['desktopicon'],
)
..addTasks(
name: 'desktopicon',
description: '{cm:CreateDesktopIcon}',
groupDescription: '{cm:AdditionalIcons}',
flags: [TaskFlag.unchecked],
)
..addSetup(
key: 'UninstallDisplayIcon',
value: '${Inno.app}\\${Config.execName}',
)
..addSetup(
key: 'UninstallDisplayName',
value: '${Config.appName}',
)
..addSetup(
key: 'DisableWelcomePage',
value: 'no',
)
..addSetup(
key: 'WizardImageFile',
value: join(assetsPath!, 'WizImage.bmp'),
)
..addSetup(
key: 'WizardSmallImageFile',
value: join(assetsPath!, 'WizSmallImage.bmp'),
)
..addSetup(
key: 'SetupIconFile',
value: join(assetsPath!, 'SetupIcon.ico'),
)
..addSetup(
key: 'PrivilegesRequiredOverridesAllowed',
value: 'dialog',
)
..addFiles(
source: join(assetsPath!, 'msvcp140.dll'),
)
..addFiles(
source: join(assetsPath!, 'vcruntime140.dll'),
)
..addFiles(
source: join(assetsPath!, 'vcruntime140_1.dll'),
)
..addSetup(
key: 'VersionInfoVersion',
value: '${Config.buildNumber}',
);
if (File('LICENSE').existsSync()) {
generator.addSetup(
key: 'LicenseFile',
value: join(Directory.current.path, 'LICENSE'),
);
}
final script = generator.toString();
final scriptPath = join(mode.installerPath, 'setup_script.iss');
final scriptFile = File(scriptPath);
await scriptFile.writeAsString(script);
return scriptFile;
}