Installing the library in the standard repository
Compiled PLC libraries can be installed in the standard repository via the Automation Interface. This enables automated build processes that require libraries to be available before compilation.
The call is made via InstallLibrary on the References node of the PLC project. The method expects the repository name, the file path to the library, and a boolean overwrite parameter. With overwrite = false, the call is canceled if the library is already installed. overwrite = true will overwrite an existing version. The repository name "System" refers to the default TwinCAT repository.
Requirements
- TwinCAT XAE is installed and started.
- A DTE connection to the target instance is active.
-
ITcSysManageris initialized in an STA thread. - A compiled library is available as a
.compiled-libraryor.libraryfile. - A PLC project containing a
Referencesnode is included in the solution.
C# sample
ITcSmTreeItem references = sysManager.LookupTreeItem(@"TIPC^PLC1^PLC1 Project^References");
// Install into the default repository
references.InstallLibrary(
"System", // repository name
@"C:\Libraries\MyLib_A.compiled.library", // library file path
false); // do not overwrite
PowerShell sample
# Look up the References node of the PLC project
$references = $sysManager.LookupTreeItem("TIPC^Untitled1^Untitled1 Projekt^References")
# Install library into the default repository ("System")
# Parameters: repository name, file path, overwrite (bool)
$references.InstallLibrary("System",
"C:\Libraries\MyLib_A.compiled.library",
$false) # $false = do not overwrite if already installed