Can I gitignore the .tmcRefac and .tpr files in TwinCAT?

Viewed 289

Whenever you refactor a TwinCAT project, it creates a .tmcRefac file. After building this file gets converted into a .tpr file. What are these files exactly and can I add them to my .gitignore file?

1 Answers

Short answer

The .tmcRefac can be ignored as also mentioned here and it was included in the official GitHub gitignore for TwinCAT. The .tpr file can't be ignored, because it contains important information about the rename history for the System Manager.

Long answer

The .tmcRefac file contains information about which variable got renamed to what:

<?xml version="1.0" encoding="utf-8"?>
<Refactors>
  <Renames>
    <RenamedSymbol>
      <Type guid="904700f4-ab78-477a-973a-562c3c32f400">MAIN</Type>
      <From>number1</From>
      <To>number2</To>
    </RenamedSymbol>
  </Renames>
</Refactors>

After building the project with TwinCAT 4024.12 this files seems to get removed. However, if you have a stand alone plc project, it gets converted into a .tpr file. This .tpr file again contains information about the refactored variable:

<TcModuleRefactorInfos RefactorCnt="1">
  <TcModuleRefactorInfo RefactorCnt="1" DateTime="2021-11-11T10:46:12">
    <Renames>
      <RenameSymbol>
        <From>MAIN.number1</From>
        <To>MAIN.number2</To>
      </RenameSymbol>
    </Renames>
  </TcModuleRefactorInfo>
</TcModuleRefactorInfos>

Beckhoff support says about this file:

The .tpr file is required to save the rename history of I/O variables in a stand-alone PLC project, since the PLC project and the System Manager are not in the same project. I don't think you should ignore the file as it is relevant to the rename history.

Bug

If you're running TwinCAT 4024.10-4024.12 there can be a bug which crashes Visual Studio/XAE when a .tpr file is present. Solution is to upgrade to > 4024.15.

Related