As already discussed in the article on Model Design, the OPC Foundation provides a free tool called ModelCompiler that allows you to generate classes and configuration files necessary for the development of an OPC UA server.

The project, freely downloadable from the GitHub repository, is however only executable on Windows platform.

There are methods to use the tool on Linux but is based on the use of docker and is not known if it is possible to take advantage of this solution on Mac systems.

In this article, therefore, I present a solution that makes the ModelCompiler completely cross platform, using the .NET Core platform.

Before we start, I remind you that in order to compile and correctly run the project that we are going to download shortly, you need to have the .NET Core 3.1 SDK installed on your system.

For the installation, please refer to the official Microsoft download page.

Cross Platform Model Compiler

The ModelCompiler that I’m going to present is nothing but a fork of the original repository of the OPC Foundation, where I’ve eliminated and replaced the parts of the project that used libraries compilable only in Windows.

In this way I obtained a project based on .NET Core, that for its cross platform nature, allows us to use the ModelCompiler in any supported operating system.

To download the project, we can mainly do two things.

1. Clone the Git repository via the command:

Copy to Clipboard

2. Download the project from this link.

In both cases we will find a solution that we can either open with a development IDE such as Visual Studio or Visual Studio Code to freely edit and compile it.

The project has no particular dependencies to satisfy as I have included the latest version of the OPC UA libraries inside.

If you use a development editor such as Visual Studio Code, once you open the project, you will only need to run the following command to compile it successfully:

Copy to Clipboard

When finished, in the project folder binDebugnetcoreapp3.1 you’ll find all the files needed to use the ModelCompiler.

At this point, for specific details on how to perform the compilation of a complete model, I refer you to this article where I show how to write a data model needed to then develop an OPC UA server.

Obviously, differently from what reported in the article just mentioned, if you don’t operate in a Windows environment to correctly launch the compilation command, we will have to execute from console the following instruction (omitting the .exe extension):

Copy to Clipboard

Conclusions

The OPC Foundation has developed the OPC UA stack based on the .NET Core framework that allows it to make the libraries compatible with all operating systems currently in use. In the case of the ModelCompiler tool, very useful for those who want to develop OPC UA servers, the implementation choice was to write a Windows-based application, failing the cross platform nature of the entire ecosystem.

As mentioned in the introduction, there are methods to run the same tool on Linux, but they are still systems that try to put a patch to a project that in itself deserves to be made more general and cross-platform.

In this article, therefore, we’ve seen a simple solution that you can freely download from my repository, in which the ModelCompiler has been cleaned up from any reference that would affect the execution on systems other than Microsoft.