Developer Center Blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Take Your VI Package to the Next Level with Custom Actions

David_L
Active Participant

VI Package Manager is a very powerful tool for distributing and installing LabVIEW toolkits and add-ons.  There are tons of features for customizing your palettes, install destinations, licensing, etc in almost every way that is needed.  However as a developer,you may occasionally find yourself needing a little more control of your package that may not be directly supported in VIPM.  In these situations, you may use custom actions to unlock the full potential of your product.

custom action 2.png

Custom Actions

For those unaware of this powerful feature, custom actions are VIs that execute during the build or installation process of a VI Package.  They are standard LabVIEW VIs that run in the LabVIEW development environment, so anything that you can do in LabVIEW can be added to your build or install process.  There are three main types of custom Actions: 

  • Install Actions run before or after an end user installs your package
  • Uninstall Actions which run before or after a user uninstalls your package
  • Build Actions run before or after VIPM builds the .vip file (note that Build Actions are only available in VIPM Pro)

Parameters

One feature of Custom Actions that really makes them powerful is their use of Parameters that are passed from VIPM.  Parameters are passed via Variant Attributes into each Custom Action VI and can be used to make decisions based on information from the users (or developers) system.  Not every parameter applies to every Action type, but below are some parameters you may find useful:

  • Package Display Name
  • Package Name
  • LabVIEW Target Version
  • VIPM Version
  • Quite Mode
  • Mass Compile On
  • Files Installed
  • Folders Created
  • Files Uninstalled
  • Files Not Uninstalled
  • Refresh Palettes On
  • Output Package File Path
  • Package Member Source Files
  • Passwords
  • Product Name
  • Package Version
  • Package LabVIEW Version
  • Package Source Folder
  • Package Name
  • Build Failure

custom action 1.png

Error Output

All custom Action VIs have an error output which passes an error back to VIPM.  If an error occurs in the custom action VI, then installation/uninstallation/building is aborted and an error is displayed to the user.

Common Uses

As I mentioned, you can use custom actions to do almost anything that is possible in LabVIEW.  However a few ways custom actions can be useful are:

  • Zip/unzip files that you don't want mass compiled during install time.  Use a pre-build VI to zip the files and, install the zip file to a temporary location and then use a post-install VI to extract them into the appropriate folder.
  • Prevent a package from installing on newer versions of LabVIEW.  Use a pre-install step to check the LabVIEW version and return an error if the package should not install on the system.
  • Restart LabVIEW after installation.
  • Rename or make changes to components created during installation such as palettes, source files/folders, VIP files, etc.
  • Read or write from the registry

Getting Started

Creating your own custom actions is easy.  In your VIPM build specification, simply click the Custom Actions tab and then click Generate VI for the desired action.  This will create a VI in your build directory with the appropriate connector pane.  The Parameters variant is also added to the block diagram with code that breaks out the parameters that are useful in the specific type of custom action.  Simply use data extracted from the variant to start programming your custom action. 

Do you have any other interesting uses for Custom Actions or advice to other developers?  If so leave a comment below.


Comments