The information in this post are usable with:
- VisualStudio 2017, 2019
If there is a project in a solution that can be transferred to an HMI NuGet package (e.g. TwinCAT HMI Framework Project), the “Included in Solution”-flag of the corresponding reference in an HMI-project can be used to automatically reinstall this NuGet package.
The flag is provided in the PropertyPane of the respective NuGet reference in an HMI-project:
In the screenshot above, the NuGet package “TcHmiBaseControls” is generated from the TwinCAT Framework Project “TcHmiBaseControls”. If the TwinCAT Framework Project is triggered for a “Build” (i.e Ctrl+Shift+B), the HMI environments checks if any HMI-project is referencing that NuGet identifier and if the flag is set to “True”. If all conditions are true, after the build of the TwinCAT HMI Framework Project, automatically a new NuGet package is created and all corresponding HMI-project will reinstall the new generated NuGet package.
The main advantage of that parameter/flag is an easy way to check valid NuGet packages based on your control architecture and if they can be loaded and used by customers.
Let us check this by an example…
Create a simple TwinCAT HMI Project and a base TwinCAT HMI Framework Project:
Open the file “MyButtonPkgControl\Style.css” and add a CSS-background property for better visualization for that small demonstration:
Call “Create NuGet package…”:
Build the project of prompted:
Wait for the finished “Pack”-process:
The new NuGet package is automatically stored in one of the HMI default NuGet-galleries,
i.e. “C:\TwinCAT\Functions\TE2000-HMI-Engineering\References” and can be used directly by using the NuGet Package Management Pane.
Select “TwinCAT HMI Customer” for “Package source”:
Select the recently created and added NuGet package “MyButtonPkg” and click install.
After that step the NuGet package is installed to the HMI-project and a new reference has been added below the “References”-node. Select the reference with the caption “MyButtonPkg” and open the PropertyPane (i.e. <F4>), the flag “Included in Solution” should be present.
Change the value to “True”.
Open the “Desktop.view” and drop an instance of “MyButtonPkgControl”:
Change “background: red;” to “background: purple;” in the Style.css and click Build for the TwinCAT Framework Control Project. After that few steps a NuGet-pack command is called again:
When finished, the Desktop.view is locked and must be reloaded (sometimes it must be reopened).
As a result the control has been updated and will shine in purple: