getMachineInnoExec static method

File? getMachineInnoExec({
  1. bool throwIfNotFound = true,
})

Locates a machine-wide or per-user install of Inno Setup (ISCC.exe).

Checks the system directory (innoSysDirPath) then the user directory (innoUserDirPath). Installs whose reported version is below minSupportedVersion are treated as if they don't exist (left in place, never used). When throwIfNotFound is true (the default), prints a guidance link via CliLogger and exits if no usable install is found or it appears corrupted; otherwise returns null.

Implementation

static File? getMachineInnoExec({bool throwIfNotFound = true}) {
  if (!Directory(p.joinAll(innoSysDirPath)).existsSync() &&
      !Directory(p.joinAll(innoUserDirPath)).existsSync()) {
    if (throwIfNotFound) {
      CliLogger.exitError("Inno Setup 6 is not detected in your machine, "
          "checkout our docs on how to correctly install it:\n"
          "${CliLogger.sLink(innoDownloadStepLink, level: CliLoggerLevel.two)}");
    }
    return null;
  }

  final sysExecPath = p.joinAll([...innoSysDirPath, "ISCC.exe"]);
  final sysExecFile = File(sysExecPath);
  final userExecPath = p.joinAll([...innoUserDirPath, "ISCC.exe"]);
  final userExecFile = File(userExecPath);

  for (final exec in [sysExecFile, userExecFile]) {
    if (!exec.existsSync()) continue;
    final version = machineInnoVersion(exec);
    if (version != null &&
        compareVersions(version, minSupportedVersion) < 0) {
      if (throwIfNotFound) {
        CliLogger.exitError(
            "Detected Inno Setup $version on your machine, but inno_bundle "
            "supports $minSupportedVersion and newer. Install a supported "
            "version with `dart run inno_bundle:setup_versions` or check "
            "our docs:\n"
            "${CliLogger.sLink(innoDownloadStepLink, level: CliLoggerLevel.two)}");
      }
      continue;
    }
    return exec;
  }

  if (throwIfNotFound) {
    CliLogger.exitError(
        "Inno Setup installation in your machine is corrupted "
        "or incomplete, checkout our docs on how to correctly install it:\n"
        "${CliLogger.sLink(innoDownloadStepLink, level: CliLoggerLevel.two)}");
  }
  return null;
}