Addon/Toolbox Post Install Hooks

9 次查看(过去 30 天)
Alexander
Alexander 2023-3-29
评论: Alexander 2023-3-31
I was wondering if there is any form of post install hooks for add-ons and downloads. Depending on the environment an installation happens in there may be a need to apply some post install configuration. I couldn't find anything in the docs or Package Toolbox dialog. Was hoping somebody else has found a solution that I may not have found in the docs.
The ideal solution would be one that works in interactive (GUI, Command Window) and non interactive environments (CI, deployments, scripts etc).

回答(1 个)

Jack
Jack 2023-3-29
Yes, there is a way to run post-installation code after installing a MATLAB add-on or toolbox using the MATLAB Add-On Manager.
You can create a file named "startup.m" in your MATLAB user folder or project folder. MATLAB automatically runs this file when it starts up, and you can use it to run any custom code you want.
To run post-installation code after installing an add-on or toolbox, you can add the code to the "startup.m" file, and MATLAB will run it the next time it starts up. You can use conditional statements to make sure that the post-installation code only runs if the add-on or toolbox has been installed.
For example, you can use the "isToolboxInstalled" function to check if a specific toolbox is installed, and then run the post-installation code if it is. Here's an example:
if isToolboxInstalled('myToolbox')
% Run post-installation code here
end
Similarly, you can use the "isAddonEnabled" function to check if a specific add-on is enabled, and then run the post-installation code if it is. Here's an example:
if isAddonEnabled('myAddon')
% Run post-installation code here
end
You can also use other functions and commands in the "startup.m" file to configure your MATLAB environment or load specific settings and preferences.
Note that the "startup.m" file is run every time MATLAB starts up, so make sure your code is efficient and doesn't cause unnecessary delays or errors.
  5 个评论
Jack
Jack 2023-3-31
I apologize for the confusion. The install function I mentioned is actually part of the MATLAB Add-On Explorer and is used to install add-ons from the MATLAB Central File Exchange or other repositories.
To install support packages in MATLAB, you can use the "Add-Ons" menu in the MATLAB desktop interface:
  1. Click on the "Add-Ons" dropdown menu in the MATLAB desktop interface.
  2. Select "Get Add-Ons" to open the Add-On Explorer.
  3. In the "Available Add-Ons" tab, search for the support package you want to install.
  4. Click on the support package to open its details page.
  5. Click the "Install" button to download and install the support package.
Alternatively, you can use the supportPackageInstaller function to install support packages programmatically from the command line. Here's an example code snippet:
supportPackageInstaller % open the support package installer GUI
This code should open the support package installer, where you can select and install the support package you need.
I hope this helps! Let me know if you have any further questions.
Alexander
Alexander 2023-3-31
No problem, thanks for explaining that. I updated my original question since an ideal packaging solution works for interactive and non interactive environments. I did want to mention it looks like supportPackageInstaller is actively discouraged by Mathworks in the docs.
Do you know of an install api method available from the command window that also handles post install scripts, or only the GUI AddOn view?
Appreciate your help and all the information.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by