Skip to content

What actually controls a macOS DMG install window in electron-builder: the background image, not config

TL;DR.

With electron-builder 26's dmg target, the Finder window's size IS the 1x background image's pixel dimensions — there is no window-size setting, the image never scales, and a stale @2x file silently masks your art edits on retina displays. Measured layout rules included.

BLUF: you cannot set a DMG install window's size or make its background scale. Finder stores a fixed content rect in the volume's .DS_Store, and with electron-builder's dmg target that rect is exactly the 1x background image's pixel dimensions. Every layout problem is solved by changing the image, never by config. Learned over several rebuild cycles with electron-builder 26 on macOS.

The window is the image

The task was "make the background scale with the window / lock the window size." Neither is buildable. The background image renders at 1:1; the window is sized to it. Our first attempt cropped the art tighter to fit the icons — wrong lever: the band the icons must sit in was a fixed fraction of the image height, so it grows with window size, not with cropping. The correct fix was shipping the art at a larger pixel size (540×380 → 600×400). Re-crop or re-size the art; never expect scaling.

Measured layout rules

  • Coordinates in dmg.contents are icon centers, in 1x pixels, origin top-left. Icon labels sit ~20px below icon center.
  • Content past the right edge draws a permanent horizontal scrollbar. Finder pads ~55px past the rightmost icon label: at 540px wide, an Applications link centered at x=455 scrolled; x=435 didn't.
  • dmg.iconSize defaults are version-dependent — leave it unset and an electron-builder bump can silently shift icon/label layout onto unusable parts of your art. Pin it explicitly.

The stale @2x trap

On retina displays your edits can be invisible: electron-builder merges the 1x file and its @2x sibling (found by filename suffix) into a multi-resolution TIFF via tiffutil, and a retina Finder renders only the @2x half. We replaced the 1x background, rebuilt, and the DMG would have shown the old art with no error — the @2x file was still the old image. Always regenerate both files as a pixel-exact 2× pair (an upscaled 1x works as a stopgap).

Takeaway

Treat the DMG window as a bitmap you're compositing, with the icon coordinates as part of the artwork. Config controls almost nothing; the image and the measured Finder constants above control everything.

No signals yet