Renaming TwinCAT C++ projects

The automated renaming of TwinCAT C++ projects is not possible.

At this point instructions will be given on manually renaming a project.

In summary, one can say that the C++ project will be renamed together with the corresponding files.

A project, "OldProject", exists and is to be renamed "NewProject".
1. If TcCOM instances exist in the project and are to be retained along with their links, first move them by drag & drop out of the project into System->TcCOM Objects.
2. Remove the old project from the TwinCAT Solution using Remove. Renaming TwinCAT C++ projects 1:
3. Compilations of the "OldProject" can be deleted. To do this, delete the corresponding .sys/.pdb files in "_Deployment".
Any existing .aps file can also be deleted.
4. Rename the C++ project directory and the project files (.vcxproj, .vcxproj.filters).
If version management is in use, this renaming must be carried out via the version management system.
5. If a .vcvproj.user file exists, check the contents; this is where user settings are stored. Also rename this file if necessary.
6. Open the TwinCAT Solution. Re-link the renamed project to the C++ node using Add existing item: navigate to the renamed subdirectory and select the .vcxproj file there.
7. Rename the ClassFactory, services and interfaces as well as header/source code files to the new project name. In addition, rename the TMC file and the corresponding files in the project folders "TwinCAT RT Files" and "TwinCAT UM Files".
This renaming should also be mapped in the version management system; if the version management system is not integrated in Visual Studio, this step must also be carried out in the version management system. Replace all occurrences in the source code (case-sensitive):
"OLDPROJECT" becomes "NEWPROJECT" and "OldProject" becomes "NewProject".
Use the Find and Replace dialog in Visual Studio for this; note that the "NewProject Project" in the Solution Explorer has to be selected.
Renaming TwinCAT C++ projects 2:

Note

Incorrect source code

The simple renaming of all occurrences of the character string may result in incorrect source code, for example if the project name is used within a method name.

  • If such occurrences are possible, carry out the renaming individually (Replace instead of Replace All).

How to build the project:

1. A) If instances from the project should exist, update them. To do this, right-click on the instance, select TTMI/TMC File->Reload TMI/TMC File… and select the renamed new TMC file.
Renaming TwinCAT C++ projects 3:
B) Alternatively, carry this out via System->TcCOM Objects and the Project Objects tab by right-clicking on the OTCID.
2. Move System->TcCOM into the project.
3. Clean up the target system(s).
For TwinCAT C++ driver: Delete the files "OldProject.sys/.pdb" in C:\TwinCAT\3.x\Driver\AutoInstall.
For TwinCAT Versioned C++ projects: The repository can be cleaned up below C:\TwinCAT\3.1\Repository
4. Test the project.