Notes on handling

Template in customer-specific directory

Templates can also be stored outside of the usual TwinCAT directory.

1. In the registry, expand the search path (in this case V12.0, i.e. for VS 2013) in which the node /2 is created:
Registry Key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Projects\{B9B2C4C6-072A-4B72-83C1-77FD2DEE35AB}\AddItemTemplates\TemplateDirs\{3d3e7b23-b958-4a99-bfee-d0d953c182d4}\
Notes on handling 1:
2. Increase the SortPriority.
3. Recommendation: in the directory, create a subdirectory called Class, which is entered in the registry, and a subdirectory called Templates in order to separate the .vsz / .vsdir / .ico files from the templates.
4. Adapt the paths within the files.
As a result, a dedicated order exists for the templates:
Notes on handling 2:

This directory or directory structure can, for example, now be versioned in the version management system and is also not affected by TwinCAT installations/updates.

Quick start

A general entry to the wizard environment in the MSDN is the entry point: https://msdn.microsoft.com/de-de/library/7k3w6w59%28v=VS.120%29.aspx.

This describes how a template is used for creating a customer-specific module with the TwinCAT C++ Module Wizard.

1. Take an existing module template as the copying template
In C:\TwinCAT\3.x\Components\Base\CppTemplate\Templates
Notes on handling 3:
2. Rename the .xml file within the folder
Notes on handling 4:
3. Copy the corresponding files .ico / .vsdir / .vsz also in the Class/
Notes on handling 5:
4. Now reference the copied .vsz file in the .vsdir file and adapt the description.
5. Enter the .xml file created in step 2 in the .vsz file.
6. You can now make changes to the source files in the Template/CustomerModuleCyclicIO/ directory. The .xml takes care of replacements when creating a project from this template.
The TwinCAT Module Class Wizard now displays the new project for selection:
Notes on handling 6:

If the vsxproj, for example, are also to be provided in a changed form, it is recommended to adapt a copy of the TwinCAT C++ Project Wizard.

If necessary, the use of settings in .props files should also be considered so that settings can also be changed in existing projects created from a template – e.g. as a result of the .props files being updated by a version management system.

Alternative creation on the basis of an existing project

A viable way here is to create a finished project and transform it into a template afterwards.

1. Copy the cleaned project into the Templates\ folder.
2. Create a transformation description (XML file).
3. Prepare the source files and the project file by means of the replacements described.
4. Provide the .ico / .vsdir / .vsz files.