Resolving Library Dependencies
For the resolution of library dependencies, the full dependency graph is determined from the Libraries.json reference list and written to the Libraries.lock.json lockfile.
A library resolution is run when a library is created for the first time. After that, it is explicitly triggered by the user. After an initial creation of a device project, the library resolution runs automatically one time, but never again automatically, not even when opening a project. As a result, changes to the dependency graph never go unnoticed.
To resolve the libraries, you use the Resolve Libraries command in the context menu of the Libraries.json file. References are taken into account when they do not yet have a resolution or when their stored resolution no longer matches the definition in the Libraries.json file.
The Resolve All Libraries command will rebuild the entire graph.
Resolution process
The dependency graph is built recursively. For each referenced library, its own references are also resolved. In this way, the graph is gradually expanded until all dependencies have been determined.
When a library is referenced via a version pattern, all available library sources are examined during resolution in order to determine the best matching version. Sources include the library cache and all configured library repositories.
Priority for resolution:
A reference is resolved according to a fixed ranking. The first applicable rule wins.
Reference via a relative path
Reference with a fixed version of the library
Reference with a version pattern: the latest matching version is selected
Placeholders with an override in
Libraries.json(placeholderOverridessection)Placeholders resolved by a component or extension of CODESYS 4
Placeholders with a unique resolution from the device descriptions
Path in the device description:
library-management\placeholder-libraries\
Errors and conflicts
If a conflict occurs during library resolution, then the process is aborted with an error. In this case, no lockfile is created.
A conflict exists in the following cases:
The same library is resolved to different fixed versions.
Different libraries are resolved for the same namespace.
A library is referenced simultaneously via a fixed version and via a version pattern that does not match.
Different device descriptions resolve the same placeholder in a conflicting manner.
This case does not occur when a placeholder override in the
Libraries.jsonfile already uniquely defines the placeholder.
An error message will also be issued when a required library cannot be resolved. If an optional library cannot be resolved, then only a diagnostic message is generated. In this case, the library is skipped and the resolution continues.
After the resolution
After the resolution, the libraries will be made accessible. A library with a relative path is checked for a valid path. If the path points to a source library project, then the project will be loaded into the workspace as an editable project. All remaining libraries will be restored from their sources into the library cache, as long as they do not already exist there. The path in the lockfile will then point to the location of the library in the library cache.