Copying a Project in ModusToolbox 2.0

Usually, copying projects in Eclipse-based IDEs is simple, but ModusToolbox 2.0 appears to have a bug that requires a bit of extra effort on our part to correct for.

This first thing to do is right-click on the name of the project you want to copy in the Project Explorer and choose Copy

Then, right-click in a blank area of the Project Explorer and choose Paste.

In the resulting dialog box, give the project copy a new name (or stick with the default) and click Copy.

image

The project copy will now appear in the Project Explorer along with the original. However, by selecting the original project and then selecting the project copy, we can see that the Launch configurations were not properly updated after being duplicated. The project copy has no available launch configurations to choose from while the original project contains duplicates.

The simplest way I have found to correct this issue is by modifying the launch configuration files of the project copy directly. These files are located in the workspace/<project_name>/.mtbLaunchConfigs/ directory.

You can see below that these files are still named after the original project rather than the name given to the project copy. So, the first thing to do is rename the files, substituting the new name for the original name. You can do this manually in the file explorer of your choice, but I’ll use a terminal as it’s faster (and easier to show in a screenshot :wink:).

image

Next, we have to change the contents of the configuration files by replacing all occurrences of the original project name with the name of the project copy. Again, this is easier to demonstrate using the terminal. Notice that after the sed command is executed, all instances of “myProject” have been changed to “myProject_copy”.

Now, going back to the IDE and again selecting the original project and the project copy, we can see that the launch configurations are correct.

You should now be able to build, debug, and program the copy of your application.