Main Content

matlab.addons.toolbox.packageToolbox

R2026b

Build package from project file

Description

matlab.addons.toolbox.packageToolbox(projectFile) packages the project file (.prj file) into a MATLAB® package file (.mltbx file). The name of the resulting MATLAB package file is the name of the package appended with the .mltbx extension. For example, packagename.mltbx.

For you to build a package, the package root folder and the package files must be in the same location as when you created the project file.

example

matlab.addons.toolbox.packageToolbox(projectFile,outputFile) builds the package and saves the .mltbx file with the name and location specified by outputFile.

example

matlab.addons.toolbox.packageToolbox(opts) builds the package with the options specified by the ToolboxOptions object opts. (since R2023a)

example

Examples

collapse all

Assume that you have the myPackage.prj package project file in your current working folder. Build the package in the same folder.

projectFile = "myPackage.prj";
matlab.addons.toolbox.packageToolbox(projectFile)

Assume that you have the myPackage.prj package project file in your current working folder. Build the package as myFavoritePackage.mltbx.

projectFile = "myPackage.prj";
outputFile = "myFavoritePackage";
matlab.addons.toolbox.packageToolbox(projectFile,outputFile)

Since R2023a

Use a ToolboxOptions object to build a package named My Package that is supported on all platforms except macOS and is compatible with R2026b and later releases. The package also has one required add-on and one required additional software package.

uuid = "75442144-f751-4011-bf0e-32b6fb2f1433";
packageFolder = "C:\Work\myPackage";
opts = matlab.addons.toolbox.ToolboxOptions(packageFolder, uuid);

opts.ToolboxName = "My Package";
 
opts.SupportedPlatforms.Win64 = true;
opts.SupportedPlatforms.Mac = false;
opts.SupportedPlatforms.Glnxa64 = true;
opts.SupportedPlatforms.MatlabOnline = true;

opts.MinimumMatlabRelease = "R2026b";
opts.MaximumMatlabRelease = "";

opts.PackageDependencies = matlab.mpm.Dependency(...
           "Gui Layout Toolbox", ...
           ">=4.2.0", ... 
           "e5af5a78-4a80-11e4-9553-005056977bd0");

opts.RequiredAdditionalSoftware = ...
    struct("Name", "Dataset", ...
           "Platform", "common", ...
           "DownloadURL", "https://github.com/myusername/myproject/data.zip", ...
           "LicenseURL", "https://github.com/myusername/myproject/LICENSE");

matlab.addons.toolbox.packageToolbox(opts);

Input Arguments

collapse all

Project file (.prj), specified as a string scalar or character vector. When specifying projectFile, include the relative or absolute path to the file. The specified MATLAB project must contain exactly one package task. (since R2025a)

For a package created before R2025a, you can specify projectFile as the package project file (.prj).

Example: "myPackage.prj"

Example: "C:\Work\myOtherPackage.prj"

Name of the output MATLAB package file (.mltbx file), specified as a character vector or string scalar. The name includes the relative or absolute path to the file. If the value of outputFile does not contain the .mltbx extension, the package function appends the extension.

Example: "myPackage.mltbx"

Example: "C:\Work\myOtherPackage"

Since R2023a

Package options, specified as a ToolboxOptions object.

Alternatives

You can build packages from the Build Package UI. For more information, see Interactively Create and Share Packages.

Version History

Introduced in R2016a

expand all