Skip to content

The folder and the nuspec

A TwinCAT package is a NuGet package: a .nupkg file, which is a zip. Rename one to .zip and open it, and everything this section describes is in there. The Package Manager adds two conventions on top of NuGet. The metadata file describes the package the way the GUI shows it, and a tools folder holds PowerShell scripts that do the actual install. Those scripts follow the Chocolatey naming, which is why they are called chocolateyinstall.ps1 and not something Beckhoff picked.

This page and the three after it build one package, from an empty folder to an installed package. The steps are numbered across the pages:

The package is MyCompany.XAE.Docs.MyMachine. It copies a folder of machine documentation onto engineering PCs. It is small on purpose, so the structure shows. The examples use the same structure for a PLC library, a Windows service, a certificate and a route file.

Step 1: the folder

One folder per package, named after the package id:

MyCompany.XAE.Docs.MyMachine\
  MyCompany.XAE.Docs.MyMachine.nuspec           the metadata
  MyCompany.XAE.Docs.MyMachine.ReleaseNote.md   the GUI's Feature Release Notes tab
  docs\                                          the files the package installs
    MyMachine Manual.pdf
    MyMachine Wiring.pdf
  tools\
    chocolateyinstall.ps1                        runs on install and on upgrade
    chocolateyuninstall.ps1                      runs on uninstall
    chocolateybeforemodify.ps1                   runs before an upgrade or uninstall touches files

The files the package installs are the payload. Here that is docs\. The payload can sit anywhere in the source folder. What matters is where the nuspec puts it inside the package, because the install script finds it relative to itself. This package puts it in tools\docs, next to the scripts.

Step 2: the nuspec

The nuspec is an XML file. Every field the GUI shows comes from here. Start from this one and change the values:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>MyCompany.XAE.Docs.MyMachine</id>
    <version>1.0.0</version>
    <title>MyMachine Documentation</title>
    <authors>MyCompany</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <readme>MyCompany.XAE.Docs.MyMachine.ReleaseNote.md</readme>
    <summary>Manuals and drawings for MyMachine</summary>
    <description>Installs the MyMachine manuals and drawings under C:\Program Files\MyCompany\MyMachine\Documentation.</description>
    <tags>Beckhoff TwinCAT XAE</tags>
    <dependencies>
      <dependency id="TwinCAT.XAE.Base" version="0.0.0" />
    </dependencies>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
    <file src="docs\**" target="tools\docs" />
    <file src="MyCompany.XAE.Docs.MyMachine.ReleaseNote.md" target="MyCompany.XAE.Docs.MyMachine.ReleaseNote.md" />
  </files>
</package>

tcpkg pack refuses a nuspec without id, version, authors or description. It accepts one without title or summary, but the GUI and tcpkg list show those, so always fill them in. Verified with tcpkg 2.6.24.

Field by field:

id
The name the package is installed and upgraded by. Pick it once and never change it, because an upgrade only works when the id matches. No spaces: tcpkg pack refuses an id with a space in it. The convention the community packages follow is <Company>.<XAE|XAR>.<Kind>.<Product>, for example MyCompany.XAE.Docs.MyMachine or MyCompany.XAE.PLC.Lib.MyLibrary. Any scheme works if you keep to it on one feed. Ids that start with TcPkg are hidden by the GUI.
version
Three numbers, 1.0.0. Every change to a package needs a new version. The versioning page has the rules.
title
What the GUI prints on the card and in the package list. Plain words, spaces allowed.
authors
Your company name.
description
The GUI prints this raw, line breaks and all, on the card and on the Description tab. Write one or two plain sentences. No Markdown, no bullet points.
summary
Shown in tcpkg list output. Keep it to one line.
readme
The file the GUI shows on the Feature Release Notes tab. Beckhoff names it <Id>.ReleaseNote.md. The file must also be listed under <files>; when it is not, tcpkg pack stops with "The readme file ... does not exist in the package". Step 3 says what the file may contain.
tags

Space separated words. Most are for the reader; the Package Manager reads these, and it compares them without regard to case:

Tag Meaning
Beckhoff TwinCAT by convention every TwinCAT package starts with these two
XAE / XAR which side the package is for: engineering or runtime. A convention; the Package Manager does not act on them
Workload, Category<Name>, VariantXAE / VariantXAR make a package a workload card, see workloads
AllowMultipleVersions more than one version of this package may be installed side by side (PLC libraries use it)
AllowMultipleMajorVersions, AllowMultipleMajorMinorVersions one version per major version, or per major.minor, side by side (Beckhoff's HMI Server API packages, Beckhoff.Python); not tried for this guide
SystemServiceRestart the install restarts the TwinCAT System Service, so the GUI can warn the user
NoVisualStudioRestart the package may be installed while Visual Studio or TwinCAT XAE Shell is running. Without it, tcpkg refuses with exit code 1051 while one of them is open; with it, a test package installed with the Shell open. For a package whose files the engineering never holds open, such as a folder of documents
InstallationLevel1 the package installs without administrator rights (Beckhoff uses it on PLC libraries and HMI packages)
PackageDisclaimerMajorUpgrade, AS:<string>:AS a text the user has to accept before an upgrade across a major version; see upgrades and retiring an id
DP:<old id>:DP this package replaces the package with the old id; see upgrades and retiring an id
KM, UM, UMCompatible, VS2022, TcXaeShell64 and the like Beckhoff's own machinery for runtime-mode and Visual Studio sub-packages. Leave them off your packages: a test package tagged XAR and nothing else installed in UM mode without a word

Tags such as Setup or AutoUninstall that Beckhoff's packages carry are conventions of their build and mean nothing to the Package Manager.

dependencies
What has to be installed first. The Package Manager installs a missing dependency before your package. A dependency on a Beckhoff package takes version 0.0.0, which means any version, so your package does not refuse a newer TwinCAT. TwinCAT.XAE.Base is the engineering base package and TwinCAT.XAR.Base the runtime one; depend on the one for the side your package is for. A dependency without a version attribute also means any version; Beckhoff's packages write 0.0.0, and so does this guide. The versioning page covers dependencies on your own packages.
requireLicenseAcceptance, license and licenseUrl
Where the package's license is: <license type="file">LICENSE.txt</license> for a file inside the package, listed under <files> like any other, or <licenseUrl> for a web address. Beckhoff's component packages carry the file form, its workloads the URL form. Put the license in the package when you have one; it is the honest place for it. Do not expect the Package Manager to show it. With requireLicenseAcceptance set to true and either form, a test package installed from a folder feed and from Nexus, in the terminal and in the GUI, without a license text, a link or an accept step anywhere (tcpkg 2.6.24, GUI 2.7.6). Whether a workload gets a license step was not tried. The text a user has to accept before using your feed is the feed disclaimer, and that one works.
projectUrl, copyright, releaseNotes
Optional. The example has none of them. Beckhoff fills <releaseNotes> with build information; the GUI does not show it, and the Feature Release Notes tab comes from <readme>.
files
What goes into the package, and where. src is relative to the nuspec, target is the path inside the package, and ** takes a whole folder tree. A src that matches nothing is skipped without a word, and the package fails on the target PC instead of on your desk. Step 8 is how you catch that.

A workload adds <packageTypes> and the icon fields; those are on the workload page.

Step 3: the release notes file

The GUI shows the file named by <readme> on the Feature Release Notes tab. Its Markdown parser is very small. It understands #, ## and ### headings and plain lines of text. Bullet lists come out as [object Object]. Bold and backticks print their markers, and links print their brackets. So the file uses headings and sentences only:

## What this package installs
The MyMachine manuals and drawings, in C:\Program Files\MyCompany\MyMachine\Documentation.

## Release history
### 1.1.0
Adds the spare parts list.
### 1.0.0
First release.

Add a line under Release history with every new version. The user reads this tab to decide whether to upgrade.

On Beckhoff's feed and on a local folder feed the tab works as it is. A feed served by a NuGet server of your own, such as Nexus, hands the GUI the nuspec metadata but no file from inside the package, so there the release notes need a copy hosted next to the feed. Verified with tcpkg 2.4 against Nexus, and still so with 2.6. The hosting section shows how.

What the GUI shows, and where it comes from

In the GUI From
Card title <title>
Text on the card and the Description tab <description>, printed raw
Feature Release Notes tab the file named by <readme>
Dependencies tab <dependencies>, with their version ranges
Icon on the card the stock icon for a package; a custom one only for a workload
Version list every version of that id on the feed

Verified against the Package Manager GUI 2.2 and 2.6 and Beckhoff's own packages. When in doubt, look at what Beckhoff's packages do and copy that.

Next: step 4, the install script.