Nuget Package Management
NuGet is a package manager designed to enable developers to share reusable code. It is a software as a service solution whose client app is free and open-source. The Outercurve Foundation initially created it under the name NuPack. Since its introduction in 2010, NuGet has evolved into a larger ecosystem of tools and services.
We shall cover the following in this tutorial.
A. How to use existing Nuget packages
First, we need to tell the visual studio, where is the package source, it can be the central repository, on our own hard disk (downloaded from somewhere) or it can be built by ourselves.
=>In the Visual Studio, Tools | Nuget Package Manager | Package Manager Settings | Package Source
=>Give the right name as you like and update the source URL or other folder and press Update, the process is shown in the following image.
Figure 1: Nuget URL for sources settings
B. How to update my project from the repository that we have set:
Now we have set the package sources, now say we want to update a package or want to use a particular release, how should we do that?
=> In the Visual Studio Project | Manage Nuget Package
=> Now we can browse the package source, check our installed package, and update to the target version
Figure 2: Nuget packages update, Uninstall and version number
C. How to create my own Nuget package for the TwinCAT HMI project
Now let say, we want to create a package by ourselves and want to distribute it to the Nuget repository. We shall show it by an example that we have created in the visual studio.
=> We have an HMI project and then we have an extension project (check our extension tutorial for more), we want to make the extension project as a Nuget package and then install it to our HMI project.
=> Select the project | Create Nuget Package |
Figure 3: Nuget packages creation
If the package is already there it will show a dialog as shown in the following image.
Figure 3: Nuget package creation status
We may have a mismatch between the Nuget package from one TwinCAT HMI framework version to another. In this case, we need to update the corresponding Nuget package.
Sometimes the updated NuGet packages may not work directly, it can give a strange problem, one solution select the Nuget Package Manager Console and type then press enter
Tip 02: Sometimes, we might want to use pre release version. If the package is pre release version then you need to check the include prerelease otherwise it will not be visible and we may wonder where is my package and so on. It is shown in the following image.
Figure 4: Nuget package pre release inclusion
Tip 03: Engineering version and Nuget packages version should be matching. If these are not matching then it may work or may not work.
=> Check engineering version (Project | Server and double click on the ADS)
=> Check your package version as shown in figure 2, if you don’t have matching version then it may shown as red under the Server folder.
Figure 5: HMI Engineering version
Tip 04: You need to make sure that the package source and the package path match. For example, the paths in figure 1 are like this:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages <= note there is space in the file path after Files
If you have put wrong information about the path and have spelled wrongly or should have space where should not be and there is no space even where should have space, etc can cause problems.
Now you have reached the end of our HMI tutorial, we hope it has been useful if you have any questions you could post to our google group. If you think it can be helpful to others don’t fare to share it.
Ask questions related to Hemelix sample code and design at Google group https://groups.google.com/g/hemelix