The information in this post can be used with:
- VisualStudio 2013, 2015, 2017
- TE2000-HMI-Engineering 1.10.*.* (Download)
I was asked “Is it possible to do Publish HMI to a custom location from command line?”
Sure, this is supported but like other VisualStudio/MsBuild supported features, you have to know that we are currently name it “easteregg” or “hidden feature” because of the fact that in future the realized/implemented approaches will probably change because of new VisualStudio interfaces (a lot in VisualStudio 2019 and newer).
The “Publish” task is a normal msbuild task which we provide in “C:\TwinCAT\Functions\TE2000-HMI-Engineering\MSBuild”, “TcHmiMSBuild.Publish.dll”. The msbuild part to call that task is described in “C:\TwinCAT\Functions\TE2000-HMI-Engineering\MSBuild”, “Beckhoff.TwinCAT.HMI.targets”. The weaving between the DLL-file and the msbuild-target is within the file “Beckhoff.TwinCAT.HMI.tasks”:
To call the “Publish”-target, several information must be provided and some environment settings must be confirmed:
- the engineering HMI server MUST run, because the engineering server configuration is requested during publish and transferred to any remote server on request
- a specific publish profile MUST exist, the same publish configuration which you set up within TwinCAT HMI (see the following screenshot)
The publish profile contains a JSON-dialect, which can be edited with any texteditor or 3rd-party tools like Newtonsoft.JSON. The publish profile is stored below “Properties\” (we have to know the location, relative or absolute):
In case everything is prepared, we can publish….
$$ msbuild TcHmiProject1\TcHmiProject1.hmiproj -p:Configuration=Release -p:Platform="TwinCAT HMI" -p:TcHmi_ProjectDirectory="C:\temp\TcHmiProject1\TcHmiProject1" -t:Publish -p:TcHmi_ServerAddress="127.0.0.1" -p:TcHmi_ServerPort=1010 -p:TcHmi_ProfileName=YourProfileName -p:TcHmi_ProfilesFilename="C:\temp\TcHmiProject1\TcHmiProject1\Properties\tchmipublish.config.json" -p:TcHmi_LocalServer="ws://127.0.0.1:3000"
As you can see the following parameters are used:
|-p:TcHmi_ServerAddress=||remote server ip addr/host addr|
|-p:TcHmi_ServerPort=||remote server port, general it is 1010 or 1020 (secure)|
|-p:TcHmi_ProfileName=||see the screenshot above, here it is “YourProfileName”, the profile file can contains several different profiles|
|-p:TcHmi_ProfilesFilename=||absolute/relative path to the profile file, any file can be used or dynamically generated|
|-p:TcHmi_LocalServer=||the engineering MUST run to query server configuration|
Keep in mind, “Publish” calls a “Clean” and “Build” first. In fact, a previous manually call of “Build” is not required in this scenario:
If like to have a different behaviour, just modify the *.targets file or extend it with an additional “Publish”-target description. At the end of the day the call of publish will look like this: