How to code the checking of the version of an App ?
Mostrar comentarios más antiguos
Hello,
I made an App via AppDesigner. The App is shared via App Installer.
I woud like to code the following:
When the app is running, I would like to check the current version of the app, and check if more recent version of app exists.
How to code this ?
Many thanks
5 comentarios
Great question. I also would like a way to programmatically access the version number set in "App Details" in the Designer tab. There should be a way to access all of the fields in App Details but I haven't been able to figure that out in the recent past.
Marc Servagent
el 29 de Jul. de 2020
Marc Servagent
el 30 de Jul. de 2020
Wolf Blecher
el 10 de Mayo de 2022
Is it possible to upvote this feature request?
Respuesta aceptada
Más respuestas (1)
Brian
el 16 de Nov. de 2021
I developed the below yesterday and it has seemed to work so far.
function ver = CheckVersion(~)
if isdeployed % If compiled and deployed
[~, result] = system('path');
p = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once')); % Get run path
myDir=dir(fullfile(p,'..','appdata','components')); % Move to components folder and get all files
myDir=myDir(3:end); % Exclude '.' and '..'
validFile=myDir(datetime({myDir.date})==max(datetime({myDir.date}))); % Only look at most recent install, includes 'common' and 'platform'
appInfo=xml2struct(fullfile(validFile(1).folder,validFile(1).name)); % Import 'common' as struct from xml (requires xml2struct download)
ver=appInfo.componentData.component.componentVersion.Text; % Grab the version number as a char array
else
fullpath=mfilename('fullpath'); % Get run path
s=settings;
if ~isempty(strfind(fullpath,s.matlab.addons.InstallationFolder.ActiveValue)) % If the run path includes the addons install folder, it is run from the app bar
[p,~]=fileparts(fullpath); % Get the path
if isfolder(fullfile(p,'resources'))
xmlLocation=fullfile(p,'resources','addons_core.xml'); % Go to resources folder
appInfo=xml2struct(xmlLocation); % Import addons_core.xml as struct
ver=appInfo.addonCore.version.Text; % Grab the version number as a char array
else
ver='debug'; % This may be redundant with below. Left in to prevent errors just in case...
end
else % If run from MATLAB mlapp file
ver='debug';
end
end
end
4 comentarios
Alon Zaharony
el 6 de Abr. de 2022
Hi
Has anyone found a way to do what Adam Danz described ("programmatically access the version number set in "App Details" in the Designer tab")?
Adam Danz
el 6 de Abr. de 2022
As far as I'm aware of, there is not an option to programmatically access the apps version number (as of R2022a). Users are encouraged to make a feature request for this feature to help build support.
Brian
el 6 de Abr. de 2022
Check my comment above. It accesses the *.xml file that is created when you either compile the app into a *.exe or distribute it as an app for the app bar. From there it pulls the version number that was set in the App Details (or more specifically in the Share App window).
Francisco Sacchetti
el 19 de En. de 2024
I cannot make this work in the webbappserver
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!