PLC
Documentation

Version Latest

Libraries

See and change TwinCAT library references, placeholders, pins and namespaces with minimal diffs, save a PLC project as a library, and read and change CODESYS library references through CODESYS.

State:

FunctionState
TwinCAT references: read, add, remove, pin, unpin, namespaceModelled on the real fixture files, Linux only. Add and remove are also in the round-trip kit
TwinCAT Save PLC Project as LibraryKit shipped, not run against XAE
CODESYS references and installed librariesKit shipped, run against an engine stand-in, not against CODESYS

TwinCAT library references

Under each PLC project in TwinCAT Projects, the Libraries group shows every library item exactly as the .plcproj stores it:

  • placeholders with their default resolution (Tc2_Standard, * (Beckhoff Automation GmbH)) and the version the project pins them to;
  • references fixed by name, version and company (Tc3_Mc3Ptp,4.0.6.0,Beckhoff Automation GmbH);
  • resolutions the project keeps for placeholders it does not reference itself, pulled in by the libraries it references.

Each row says whether the version is pinned, the default (*, the newest installed), a * resolution, or fixed; the library a placeholder resolves to when it is another; the company; the namespace where it is not the name; SystemLibrary; and how many library parameters it sets. Anything else in a library item is listed as "not read" with its XML verbatim, and kept by every edit.

Commands, on a library row or in the Command Palette:

CommandWhat it does
Add Library Reference (on the PLC project row)Adds a placeholder with default resolution Name, * (Company), optionally pinned, with a namespace (the name by default). The pickers first offer what the workspace's other PLC projects reference, for example "4.0.6.0, pinned in PLC_AsyncAccessHwParameter", then accept a typed value
Remove Library ReferenceRemoves the reference with its pinned version
Pin Library VersionPins a placeholder to a version (one to four numbers, or * for the newest installed)
Unpin Library VersionRemoves the resolution so the default applies, also for a resolution the project keeps for a placeholder it does not reference
Set Library NamespaceChanges a reference's namespace

Every edit writes only the .plcproj and changes only its own lines. The confirmation names the file and lists the exact lines removed and added; the button is Change Files. Values the stored format cannot hold are refused while you type: a version that is not one to four numbers or *, a company with parentheses or line breaks, a namespace that is not an identifier or that another reference already uses, a name already referenced. A fixed LibraryReference cannot be pinned or unpinned: its version is part of its name; remove it and add the library as a placeholder.

Whether a pinned version is installed is not checked: the pickers offer only what other projects of the workspace reference, and typed values. Library parameters are shown as read.

Save a PLC project as a library

Save PLC Project as Library... (PLC project row or Command Palette) saves a PLC project as a library file on this computer through the engineering host, in the project's resident TwinCAT session.

  1. Pick the project and the PLC project when there is more than one.
  2. Pick the file in the save dialog: .library (with the source) or .compiled-library (compiled, without it).
  3. Choose whether to install it into the library repository of this computer.
  4. Read the confirmation: the project with its file count and fingerprint, the PLC project, the file, the format, the file it replaces (size and modification time) or that it is new, the install, that no controller changes, and the user name the save is logged with. The button says what happens: Save as Library, Save and Install, Replace or Replace and Install.

The save does not run when the project's files or what is at the path changed since the confirmation was shown. A file is never replaced unless the replacement was confirmed. Afterwards the file is read back; a file that is missing, empty or unchanged is reported as not known. An install cannot be read back, so the notification asks you to check the repository. The project is never saved, built or otherwise changed. Each attempt is in the PLC log.

CODESYS library references

A CODESYS project (.project) is one binary file, so its references are read and changed only through CODESYS's scripting engine, in the project's resident session. Nothing starts CODESYS until you ask.

Read. Each CODESYS project row of TwinCAT Projects has a Libraries group, empty until Read CODESYS Library References. Then each library manager is a row (Project (POUs), and <application> on <device>) with its references: name, placeholder or fixed version, namespace, system library, the library a fixed reference points to with its version, and for a placeholder its default and effective resolution and its pin. A read CODESYS could not answer is counted on the row ("2 reads failed"), never filled in. Rows say when they were read before the project file changed.

Change.

CommandWhereWhat it does
Add CODESYS Library Reference...Manager rowAdds a reference to an installed library
Add CODESYS Library Placeholder...Manager rowAdds a placeholder with an installed library as its default resolution
Remove CODESYS Library Reference...Reference rowRemoves the reference; system libraries are refused
Pin CODESYS Library Placeholder...Placeholder rowPins the placeholder to an installed library
Unpin CODESYS Library Placeholder...Placeholder rowClears the pin

The installed libraries are read from CODESYS's repositories when a change needs one. Each change ends with a choice: Change and Save, or Check without Saving, which makes the change in CODESYS's copy, reads it back and discards it. The confirmation names the project, the manager, the kind of change, the reference or placeholder, what it is pinned to now, the library with its title, version and company, whether the project file is saved, and that no controller is changed.

A change is refused, with nothing changed, while an application is logged in, while CODESYS's copy has unsaved changes, when the project file changed on disk, or when the device, application, manager, reference or library is not there. A change is kept only when the read-back shows exactly that change and nothing else; otherwise CODESYS's copy is reloaded from the file. If the project is open in CODESYS itself at the same time, that copy would overwrite the change when it is saved there; the confirmation says so.

Not verified

  • XAE resolving, building or activating a project after a pin, unpin or namespace change.
  • Save as library against XAE: whether it honours the .compiled-library extension, what it does with an existing file, how it fails for a project that does not compile, and that the install lands in the repository.
  • Every CODESYS scripting call above against CODESYS.
  • Windows; customer projects.

Last reviewed 17 October 2026View as Markdown

Libraries · Docs · Neural Inverse