# How to convert DMG to PKG Mac App for distribution

**DMG** files or Disk Image files used to install software contain app files, installation files and other file types. They are usually used by macOS software installers downloaded from the internet.

**PKG** files are macOS installation packages containing installer scripts and compressed installation files used to install Mac software applications on a user hard drive.

The issue with DMG files is that it needs to be mounted as a virtual disk to push apps, whereas PKG files can be directly installed. Hence, it is ideal to convert DMG files to PKG files to push them through Hexnode. It’s a rather simple process that can be done with the help of the **Terminal**.

Terminal can create PKG files from DMG files and they can then be distributed via Hexnode as enterprise apps.

 Note: For using downloaded DMG files:
Enable the “App Store and identified developers” option under Mac system preferences > Security and Privacy> Allow apps downloaded from.

 

PKG files can only be created from DMG files containing applications by using the Terminal.

Steps to convert macOS DMG files to PKG files.
----------------------------------------------

1. Go to the folder that contains the DMG file.
2. Double click the DMG file. It gets mounted as a
    virtual disk and reveals its contents.
3. Copy the .app file to the Applications folder in the
    macOS device.
![dmg file opens to show content.](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2019/09/Mounted-dmg-file-displaying-content.png)

5. Eject the DMG file by clicking on the eject button.
6. Open **Terminal.**
7. Build the PKG file using the **productbuild** command
`sudo productbuild --component /path_to_installedapp/macapp.app / path_to_savedpackage/packagename.pkg`

The two arguments specify the location of the installed .app file (path_to_installedapp/macapp.app) and the location to create the PKG file (path_to_savedpackage/packagename.pkg), respectively.

10. Provide the device login password and wait for a few seconds for the build to finish.
11. The PKG file gets created at the desired location.
![pkg file from dmg file gets created at the desired location.](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2019/09/Screenshot-2019-08-30-at-1.53.42-PM.png)

To distribute the created PKG files, check out [Distribute macOS Enterprise App using Hexnode.](https://www.hexnode.com/mobile-device-management/help/distribute-macos-enterprise-app-using-hexnode-mdm/)

 Note Signing a PKG file is recommended to enforce corporate data security and ensure that the app in use is trustable, safe and malware-free. Check out [How to sign pkg files for deployment.](https://www.hexnode.com/mobile-device-management/help/how-to-sign-macos-pkg-files-for-deployment-with-hexnode-mdm/)

 

The only red flag here is that not all apps are created similarly, which may affect the time required for the PKG build.