MATLAB: How to make the path length fixed for a Simulink Project Folder

simulink

MATLAB/Simulink Project stored data mirrors the project folder structure, but adds ".type.File" to each level of each path.
This in conjunction with the relatively deep default path structures used by embedded coder targets quickly exceeds the max path length of 260.
Is there a way to reduce the path overhead from Simulink Project? I am running Windows 7 so enabling long paths is still problematic.

Best Answer

The project can store its data using in a fixed path length format that solves this issue.
To change the project definition file format for an existing project:
  • Go to MATLAB's preference dialog
  • Select the project preferences and set "Project definition files:" to "use multiple project files (fixed path length)"
All new projects should now use this format. To convert an existing project to use this format.
  • Set the preferences as described above
  • Export the project to a project archive. In the project toolstrip tab: select "Share->archive"
  • Double click on the newly created .MLPROJ file. This will create a new instance of the project using the fixed path data format
If your existing project is under source control in Git, there are a few extra steps.
  • Set the preferences as described above
  • Export the project via the "Share -> archive" menu. MATLAB automatically converts the metadata folder to a "resources" folder, and all paths, shortcuts, etc are saved in this process
  • Open the exported Project in MATLAB
  • Copy the metadata folder in the exported project. Prior to R2019a, projects' metadata folders may have been in either ".SimulinkProject", or "_SimulinkProject". In new releases, the recommendation is to use "resources" as the project metadata folder which is the default in R2019a and newer.
  • Delete the metadata folder in the original Project in Git. This folder is either "resources", ".SimulinkProject", or "_SimulinkProject"
  • Add the new metadata folder ("resources" and all subfolders/files) to Git in the original Project
  • Commit changes to Git