Skip to main content

Libraries.json

This is a manifest file containing the direct library references which have been explicitly declared by the developer of the application or library. It is valid in the main directory of an application and in the root directory of a library project. The same library cannot be referenced with two different namespaces within the same Libraries.json file.

The file consists of three sections:

  • The first section references contains a JSON dictionary whose key is the namespace of the library reference and whose values are objects that describe the details of the reference. The $type member is used to distinguish between the different reference types.

  • The second section placeholderOverrides contains a JSON dictionary where the keys are the placeholder names and the values are the library IDs or patterns that override the placeholder.

  • The third section libraryParameters contains a JSON dictionary of key/value pairs. The keys of the outer dictionary can contain the following values:

    • A placeholder prepended with a hash sign (#) to reference the placeholder library

    • A LibraryId to reference the managed library

    • A relative path to reference the library project

    The internal dictionaries contain the library parameters as a key and the respective values as a value.

Member

Valid for $type

Required

Default Value

Description

$type

Yes

Type of library reference

  • ManagedLibrary: Library ID consisting of name, version, and vendor

  • RelativePath: Relative path to a library project on the hard drive

  • Placeholder: Placeholder names with a default resolution. An extension or placeholderOverrides will override this resolution if necessary.

allowUnqualifiedAccess

All

false

If the value is true, then the library can be accessed without namespace qualification. The recommended value for new code is false. This corresponds to the negation of the qualifiedOnly value in CODESYS 3, which defaults to false for historical reasons. This has an effect only if the library allows unqualified access.

publishSymbolsInContainer

All

false

If the value is true, then the referenced library will publish its symbols in the referencing container library. Use this setting to define the published symbols when creating a container library.

optional

All

false

If the value is true, then no compiler errors will occur simply because the library is unavailable. However, compiler errors may occur due to missing symbols from this library.

linkAllContent

All

false

If the value is true, then all contents of the library will be linked. This is normally used for system libraries only.

path

RelativePath

Yes

The path of the library, relative to the location of the current Libraries.json file. The path uses URI notation. Therefore, use ../ to move up one directory level, and foo/ to open the foo folder. The path points to a CODESYS 4 library project directory (*.fbslib/).

libraryId

ManagedLibrary

Yes

The library ID of the managed library, whereby the version part can be a pattern. The format of the pattern is defined in section Referencing libraries.

includePrerelease

ManagedLibrary, Placeholder

false

If the value is true, then when versions are compared, the version patterns also accept prerelease versions within the range permitted by the pattern.

If the value is false, then the versions with prerelease tags are accepted only by a version pattern when at least one comparison element – with the same [major, minor, patch] tuple within the pattern – also has a prerelease tag.

placeholder

Placeholder

Yes

The placeholder for a referenced library. It is resolved to the library ID via placeholder resolution.

defaultResolution

Placeholder

null

Optional: If this option is enabled, then all POUs will use this version (or version pattern) of the library.

Example 47. Example
{
  "references" : {
    "TESTEXTERNALS": {
      "$type": "RelativePath",
      "path": "../../../TestLib.fbslib/",
      "optional": true,
      "linkAllContent": true
    },
    "SysTime": {
      "$type": "Placeholder",
      "placeholder": "SysTime"
    },
    "Standard": {
      "$type": "ManagedLibrary",
      "libraryId": "Standard, 3.5.18.0 (System)"
    },
    "AcmeTools": {
      "$type": "ManagedLibrary",
      "libraryId": "Acme Tools, 3.5.* (Acme International Inc.)",
      "publishSymbolsInContainer": true, // comments and trailing commas are tolerated
    },
    "WsCompiled": {
      "$type": "RelativePath",
      "path": "../../../pipeline-assets/Some library.compiled-library", 
      "noHash": true
    }
  },
  "placeholderOverrides": {
    "SysTime" : "SysTime, 3.5.17.0 (System)",
    "OtherPlaceholder" : "SomeToolsLib, >=1.2.0 (SomeTools Company)"
  },
  "libraryParameters": {
    "#SysTime": {
      "ParamOne": "250",
      "ParamTwo": "true"
    },
    "Acme Tools, 3.5.* (Acme International Inc.)": {
      "ParamOne": "125"
    },
    "../../../TestLib.fbslib/": {
      "ParamThree": "125"
    }
  }
}



Referencing libraries

Just like in CODESYS 3, libraries in CODESYS 4 can be referenced via placeholders, exact library IDs, or library IDs with version patterns. Furthermore, source libraries which are available as editable libraries can also be referenced via their relative path to the Libraries.json file,

Version Pattern

Sample Syntax

Description

1.2.3.4

Corresponds exactly to the specified version 1.2.3.4

1.2.3

This corresponds exactly to version 1.2.3 or 1.2.3.0.

*

x

X

The latest available released version, but no prerelease versions.

1.2.*

1.2.*.*

1.2.x

1.2.X

The latest released patch level of version 1.2

>=1.2.3-alpha.2

Version 1.2.3 or later, including prerelease versions of 1.2.3 from alpha.2 and higher

1.0.0 - 2.0.0

1 - 2

>=1.0.0 <=2.0.0

Matches versions from 1.0.0.0 up to and including 2.0.0.0, but excluding prerelease versions

Note: Ranges with "-" require spaces around the operator in order to distinguish them from prerelease indicators: 1.0.0-2.0.0 != 1.0.0 - 2.0.0

  • 1.0.0 - 2.0.0 : range >=1.0.0 to <=2.0.0

  • 1.0.0-2.0.0 : exact version 1.0.0 with prerelease flag 2.0.0

>=1.2.3 <1.5

Accepts any version from 1.2.3 and higher, but excluding 1.5

>=1.0

Minimum version 1.0 (including)

>=1.0 <1.5||>=1.5.1 <2

All 1.x versions excluding version 1.5.0