Table of Contents

Create NuGet package

In this guide we want to focus on how you can create and publish our own NuGet Packages on an on-premises NuGet server.

Upload NuGet Package


  1. Save your PLC as a .library, either with CI/CD or manually in the TwinCAT IDE, make sure to set the following properties for your library

    • Company: Name of your company, in Twinpack we refer to this as 'distributor name'
    • Title: Name of your library as it should be seen in the TwinCAT Library Repository.
    • Version: Version number in the format x.y.z or x.y.z.w. Note that some NuGet Servers do not support 4-digit version numbers, in this case, please use a 3-digit version number
  2. In the same folder as you saved the library file, create a .nuspec file with the following content (adapt to match your specific library). The filename should match the name of the library, i.e. for the library file MyPlcLibrary.library, the nuspec file should be called MyPlcLibrary.nuspec

    <?xml version="1.0" encoding="utf-8"?>
    <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
        <id>MyPlcLibrary</id>
        <version>1.0.0.0</version>
        <title>MyPlcLibrary</title>
        <authors>MyCompany</authors>
        <description>MyPlcLibrary is an awesome library to do ...</description>
        <copyright>MyCompany</copyright>
        <tags>library</tags>
    </metadata>
    <files>
        <file src="MyPlcLibrary.library" target="TC3.1" />
    </files>
    </package>
    
    • authors must match the company of your PLC library (as set in the TwinCAT properties)
    • id and title must match the title of your PLC library (as set in the TwinCAT properties)
    • version must match the version of your PLC library (as set in the TwinCAT properties)
    • In tags you can put any additional tags, which you like, but the tag library must be included
    • In files, the .library file must be set
    • Other properties in the .nuspec file are optional
  3. Use nuget to package and push the NuGet package to your NuGet server, assuming nuget.exe is in your path environment variable and you navigated to the folder containing your .library file, this can be done with

    nuget.exe pack
    nuget.exe push MyPlcLibrary.1.0.0.nupkg -Source https://your-nuget-server -ApiKey your-api-key
    

Use NuGet package

In order to use the NuGet package you just uploaded to your server

  1. Open Twinpack in the TwinCAT IDE
  2. On the right, top corner click on Configure to add your NuGet Server as a repository for Twinpack
  3. If your repository requires authentication, you have to login. Click on the Login button and enter your personal Username and Password. If your Twinpack server only supports apikeys, leave the Username empty and put the ApiKey into the Password field.
  4. The repository configuration is saved by clicking Ok on the Package servers modal.
  5. You can now search and install the package(s) avaiable on your NuGet Server.