Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8287401: jpackage tests failing on Windows due to powershell issue
Reviewed-by: almatvee
  • Loading branch information
Alexey Semenyuk committed Jun 16, 2022
1 parent ff3db52 commit c254c9d
Showing 1 changed file with 5 additions and 8 deletions.
Expand Up @@ -28,7 +28,6 @@
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;

public final class LauncherIconVerifier {
Expand Down Expand Up @@ -136,18 +135,16 @@ private WinIconVerifier() {

private Path extractIconFromExecutable(Path outputDir, Path executable,
String label) {
Path psScript = outputDir.resolve(label + ".ps1");
Path extractedIcon = outputDir.resolve(label + ".bmp");
TKit.createTextFile(psScript, List.of(
String script = String.join(";",
"[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')",
String.format(
"[System.Drawing.Icon]::ExtractAssociatedIcon(\"%s\").ToBitmap().Save(\"%s\", [System.Drawing.Imaging.ImageFormat]::Bmp)",
"[System.Drawing.Icon]::ExtractAssociatedIcon('%s').ToBitmap().Save('%s', [System.Drawing.Imaging.ImageFormat]::Bmp)",
executable.toAbsolutePath().normalize(),
extractedIcon.toAbsolutePath().normalize()),
"exit 0"));
extractedIcon.toAbsolutePath().normalize()));

Executor.of("powershell", "-NoLogo", "-NoProfile", "-File",
psScript.toAbsolutePath().normalize().toString()).execute();
Executor.of("powershell", "-NoLogo", "-NoProfile", "-Command",
script).execute();

return extractedIcon;
}
Expand Down

0 comments on commit c254c9d

Please sign in to comment.