Azzera filtri
Azzera filtri

Check if a referenced project is available.

8 visualizzazioni (ultimi 30 giorni)
Ortinomax
Ortinomax il 19 Ago 2020
Modificato: Ortinomax il 19 Ago 2020
EDIT : I submit before finishing the question.
EDIT2 : Now there is everything.
Hello,
I am working with Simulink Projects (object of the class 'matlab.project.Project' )on Matlab R2019b, and I don't have found an acceptable way to solve it.
The issue :
A Simulink project mainProject has two others Simulink project as references parentA and parentB, wih relative path from mainProject. It works well, no issue at this point.
All projects are closed.
I removed from parentB its current directory.
Now, when I tried to open the mainProject, I get an error on the pop-up winows.
The question :
Using command, how can I check the availability of referenced projects, using an acceptable method ?
What I have done :
I open the project with the command line (the windows with the error is opened but I don't care) :
proj = openProject(cd)
The command windows show the properties of the project :
proj =
Project with properties:
Name: "mainProject"
SourceControlIntegration: ""
RepositoryLocation: ""
SourceControlMessages: [1×0 string]
ReadOnly: 0
TopLevel: 1
Dependencies: [1×1 digraph]
Categories: [1×1 matlab.project.Category]
Files: [1×0 matlab.project.ProjectFile]
Shortcuts: [1×0 matlab.project.Shortcut]
ProjectPath: [1×0 matlab.project.PathFolder]
ProjectReferences: [1×2 matlab.project.ProjectReference]
StartupFiles: [1×0 string]
ShutdownFiles: [1×0 string]
Description: ""
RootFolder: "D:\Mes_Documents\travail\testNewUser\mainProject"
ProjectStartupFolder: "D:\Mes_Documents\travail\testNewUser\mainProject"
SimulinkCacheFolder: ""
SimulinkCodeGenFolder: ""
As I can see the ProjectReferences property, I would check on them if there is an issue of availability for one reference.
>> ref1=proj.ProjectReferences(1)
ref1 =
ProjectReference with properties:
Project: [1×1 matlab.project.Project]
File: "D:\Mes_Documents\travail\testNewUser\parentA"
StoredLocation: "../parentA"
Type: "Relative"
>> ref2=proj.ProjectReferences(2)
ref2 =
ProjectReference with properties:
File: "D:\Mes_Documents\travail\testNewUser\parentB"
StoredLocation: "../parentB"
Type: "Relative"
My "ugly" way to check is to do :
try
ref1.Project;
catch err
% no error
err.identifier
end
try
ref2.Project;
catch err
% there is one, show the identifier
err.identifier
end
ans =
'MATLAB:project:api:StaleProjectHandle'
And test if I catch the error.
I would be happy to find a more acceptable method to identify missing referenced proejct.

Risposte (0)

Categorie

Scopri di più su Project File Management in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by