Programmaticaly Toolbox packaging issues

3 次查看(过去 30 天)
I have an issue with packaging a project to a toolbox programmatically.
The installed toolbox does not add the \toolbox folder to matlab path although I add all folders to opts.ToolboxMatlabPath
I have a project where I would like to only include the \doc and \toolbox folders content.
If I use the toolbox package app available throgh the project, the installed toolbox is as expected with all the relevant folders added to path. The app lets me include .p files and skip the .m files. The package optins are saved in a .prj file
Installed toolbox content
If I use the matlab.addons.toolbox.ToolboxOptions to retrive the options from the toolbox project file and package using matlab.addons.toolbox.packageToolbox I dont get the same installed toolbox. The \toolbox and the namespace +turbinelog folders are not added to path. Furthermore both .p and .m files are included.
Installed toolbox content
The below code represent my programaticaly approach.
I select only files from the project, that is within \doc or \toolbox folder and only the .p file variants
% Options for packaging toolbox project
opts = matlab.addons.toolbox.ToolboxOptions(tbxPackagingProjectFile);
% Update toolbox version
ToolboxVersion = updateVersion(opts.ToolboxVersion, releaseType); % update version based on release type [major,minor,patch,build]
opts.ToolboxVersion = ToolboxVersion;
% Files to include
prj = currentProject;
prjFiles = [prj.Files.Path]'; % files in project
[ffolder,fname,fext] = fileparts(prjFiles);
% only files in doc or toolbox folder
isToolboxFile = contains(ffolder,fullfile(prj.RootFolder,["doc","toolbox"] )); %
isFolder = isfolder(prjFiles); % use to remove folders, otherwise all files will be included
% not files having p file
ispFile = ismember(fext,".p");
haspfile = ismember(fname,fname(ispFile)) & ~ispFile;
opts.ToolboxFiles = prjFiles(isToolboxFile & ~haspfile & ~isFolder);
% Folders for matlab path
opts.ToolboxMatlabPath = unique(ffolder(isToolboxFile & ~haspfile & ~isFolder));
% Output File
buildDirectory = fullfile(opts.ToolboxFolder ,"builds");
if isempty(buildDirectory)
mkdir(buildDirectory)
end
opts.OutputFile = fullfile(buildDirectory,"DataImport_"+opts.ToolboxVersion);
% Package toolbox
matlab.addons.toolbox.packageToolbox(opts);
I hope someone can clarify where the issues is
Regards
Heine

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 COM Component Integration 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by