Skip to content

Publish TwinCAT HMI project with command line

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:

  1. the engineering HMI server MUST run, because the engineering server configuration is requested during publish and transferred to any remote server on request
  2. 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" 

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:

The msbuild target “Clean” and “Build” are executed first.
Finalizing the “Publish” execution.


  1. Rasmus Rasmus

    What about making an installer for tcHmi projects..

    Like using nsis. if you are updating +20 systems it would be nice..

    I was looking in to it, but the export/import recipe and or users is not that easy without using WS.

    Do you have any tips for this ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.