It has come to our attention that many packagers have experienced issues with packaging Arduino IDE 2 so it can be deployed in an enterprise environment. To help the application packaging community learn how we package these complex (read: poorly packaged by vendor) applications we documented a step-by-step guide.
We’re working on new self-paced courses and to test how good they are we gave to test it to our new intern Signe. She knew nothing about app packaging. All she had was course recordings, Master Packager Pro, our guidance and app to package. A hard one. Perhaps too hard. However, this is all you need. This is what we want to show. The next guide is created by Signe and proofread/checked by Toms and Edijs. Enjoy and become a Master Packager faster.
Application name: Arduino IDE 2.3.2
Link to Arduino IDE MSI installer: https://www.arduino.cc/en/software
Tools needed: Master Packager Pro (or any other repackaging software)
We are following our designed Master Packager Framework that helps to package any application in a fast and high-quality way.
To see where the application is installed refresh Master Packager Toolbox by Right-Click -> Refresh or pressing F5. Everything that was installed will be marked green. Everything that will be uninstalled will be marked red. This is excellent when doing app evaluation and testing.
Click on the Arduino IDE app row to see more details about it.
After evaluation of the installation, there are few problems that we encountered:
MSI creates desktop shortcut by default. The desktop is a user’s private space and in an enterprise deployment scenario desktop shortcuts should be removed.
MSI installs files in a per user location. Enterprises want per-machine apps. Main reasons are better security and ease of deployment when apps are per-machine.
Windows Defender Firewall displays two Windows Security Alerts when a user runs the application:
5. During first launch the application downloads libraries.
In an enterprise environment users do not have admin rights. At least they shouldn’t.
As you saw from firewall exception and driver installation popups they point to a per-user location – application checks if the library files are present in “%localappdata%\arduino15” location.
Although the software is free to download it costs money. It costs time and money for every company in world to package it or better -> re-doing the installer with hacks and tricks as you will see next.
It’s clear that this application was created without considering enterprise requirements.
Now let’s resolve these problems one by one.
Open the MSI using Master Packager and create a new Transform (MST) file. It is recommended to create MST file for every vendor MSI you want to package (modify) and deploy.
Under the shortcuts section, select desktop shortcut, right click on it and remove it.
On the left upper corner click on table icon to open Table Editor and locate Property table.
Then change ALLUSERS = 2 to 1 and MSIINSTALLPERUSER = 1 to 0. This will configure that installation will happen under [ProgramFiles] folder for all users.
Add a decade proven MSI properties that will improve MSI installation reliability.
Read about MSI reliability properties and how to apply them automatically for every package here: Improve MSI reliability with these MSI properties
To install drivers, it is usually required to have:
Install Arduino original MSI on a clean virtual machine but do not open the Arduino app itself.
Now open Arduino application.
Install drivers and tick the checkbox to always trust publisher.
After all drivers are installed, in Master Repackager check the “I am done making system changes” and create a second snapshot.
In package cleanup phase click on “Manage Registries” and find registries under Trusted publishers.
Locate dpinst-amd64.exe file and right click on it and go to file location. Make a copy of the file as it will be required later. Tip: You can use filter search on top right corner to find any file or registry faster.
To find the installed drivers you will need to check the "C:\Windows\System32\DriverStore\FileRepository” folder.
Sort the folder by date modified and you should see 8 subfolders with inf in the name. Create a new folder called Drivers. Then go into each of the driver subfolders and copy its contents to the newly created Drivers folder. Copy dpinst-amd64.exe also in the Drivers folder. Your folder should look like this:
Create a new folder called Configuration and copy the Drivers folder inside it.
How can we know which files should be included in the package?
An easy way to do is to use elimination method. Rename one of the folders by adding “_backup” at the end of the folder name, then launch the app and check if the libraries are not downloaded again. Repeat this until the libraries start to install again when launching the app. This means that you have found which folder is required for the libraries to not install again. Using this method you can quickly find that only the “%LocalAppData%\arduino15” folder is required for the libraries to be installed.
In the Master Packager Advanced Editor find Files section and right click the directory [ProgramFiles]\arduino-ide and select “Add Directory(s)” and browse for the Configuration folder and then press build now.
We will need to use predefined actions that will copy these files from the MSI to each user’s profile during system account installation that is used by most deployment systems.
To copy data to user profile we have created a predefined custom action called: “Copy to UserProfile”. It works amazingly. It copies files during system context installation to all user profiles. It also copies files to default profile so new user profiles can have the same configuration.
Under Custom Actions section, create a new Predefined action “Copy to UserProfile”. It will copy files to %localappdata% folder during the installation process.
Custom Actions → Edit → Predefined Actions → Add new Predefined Action → Copy to UserProfile
As source select arduino15 folder which was added under the configuration folder. As destination path set “AppData\Local”.
A custom action will also be added to remove these files from the default user profile during uninstallation.
For drivers to be installed silently we need to have the certificates imported to the Trusted Publishers store before driver installation.
In Advanced Editor locate Registries section → drag and drop previously exported registries.
Custom Action should look like this:
After we need to add uninstall Custom Actions for each driver:
To create Uninstall Custom Actions faster for each driver, open Table editor.
Copy CA_Uninstall_Driver row and paste (Ctrl+Shift+C and Ctrl+Shift+C to copy whole row) new Custom actions as many as drivers we have and change the file key in the Target column for each corresponding INF file key.
To find file keys go to File table and click on sequence in descending order to see last added files. Or you can use filter in the top corner and type “.inf” to filter out all INF files.
To run each created Custom Action in correct timing we need to add them in InstallExecuteSeqeuence table.
In advanced editor locate InstallExecuteSequence → Edit
First add CA_Install_Drivers:
Then add each CA_Uninstall_Driver:
Note! It’s important where each type of Custom Action is placed in the Install Execute Sequence list - CA_Install_Drivers should be place after WriteRegistries (otherwise the drivers will try to install before the certificates are installed) and CA_Uninstall_Driver before RemoveFiles action. Also, they should be placed before InstallFinalize Action.
Pro tip! This was a lot of work to install drivers. We don’t like a lot of work like that. After some time, it is hard to remember how to do it again or can introduce typo mistakes. Therefore you can create a template for driver installation using Master Packager Templates feature. Read more about how to do it here.
To create a firewall exception, add a new Predefined Action.
Open Control Panel → System and Security → Windows Defender Firewall and locate Advanced Settings
Under Inbound Rules is shown information about both needed Firewall Exceptions –for arduino ide.exe and mdns – discovery.exe
Under Custom Actions add new Predefined Action:
Set Exception name exact the same as it was by default - arduino ide.exe
Under Path select the exe file
Leave Bound, Profiles and Protocol with their default values
Set the same Exception Name also to Remove firewall exception.
Create a second firewall exception for mdns-discovery using Predefined Actions.
Select “Add Firewall Exception”
Set Exception name exact the same as it was by default - mdns-discovery.exe
Under Path set location same as default to LocalAppData Folder:
Leave Bound, Profiles and Protocol with their default values.
Set the same Exception Name also to Remove firewall exception (1).
For this firewall exception to work, we need to set up few more things:
Because Mdns-discovery exe is in user data and system account installation cannot see that location for all users, we need apply this exception during repair.
Under Register section in Advanced editor in HKEY_CURRENT_USER create a new HKCU registry Software[ProductName]. It will automatically create a corresponding component.
Open newly added registry in Table editor
Locate the corresponding component in Relationships → and double click on it
Set keypath to newly created registry key (in this case Reg_7 – Software[ProductName]) and set the Component Attributes to Registry KeyPath. This will enable Advertised Shortcut to activate MSI self-heal and register Firewall via Custom Action as in this situation Custom Action will be able to see user data path.
After all the changes in the MST are done, it’s time to wrap this package into PSADT. Master Wrapper is the fastest and safest way to create a PSAppDeployToolkit (PSADT) wrappers.
Change General information about application by loading data from the MST or just dragging and dropping the MST file into the Master Wrapper.
In the Main actions, Master Wrapper auto-generates Install, Uninstall and Repair command lines
In Pre-actions section set all the information you want to show at installation. If you use MSI/MST then it also finds and sets all the processes to be closed for upgrade. In our case if Arduino IDE is open on user end it will ask to close the application using PSADT functionality.
At post-installation you can set request to restart if needed, set force restart after a certain period or you can show custom message that you want show to the user.
Next step – at the script editor we need to add two lines:
Copy-ContentToCache function copies the toolkit files to a local cache folder. It’s necessary for the repair to work because Intune deletes the installation folder after the installation is complete.
Remove-File function will ensure that the cached folder is removed during uninstallation.
To test if the application is packaged and wrapped correctly you need to do installation through system account. To do this, you need to use PsExec.
Arduino IDE 2.3.2 is not suitable for deployment in enterprise environments. This means that you need special skills to package it. Fortunately, we’re here to help you become a Master Packager. For Master Packager Pro customers this is not a problem as:
Self-paced courses are coming soon so you can package with confidence on your own. Subscribe to our newsletter to learn when they are available.
Have an easy package!
The Master Packager Team