Skip to content

Step 2: Setup UA-ModelCompiler with Visual Studio

Last updated on October 16, 2020


This post shows how to setup the official UA-ModelCompiler with MS Visual Studio and to compile an executable binary to compile OPC UA ModelDesign files to OPC UA NodeSet files.

This Post is part of the OPC UA Information Model Tutorial.


Alternative

Instead of compiling ModelDesign files on MS Windows, the following alternative workflows are available:

Compile the ModelDesign file on Linux instead of MS Windows:
Setup ModelCompiler on Linux

Instead of editing ModelDesign files and compiling them into UANodeSet files, edit of UANodeSet files directly with appropriate editors: Setup NodeSet Editor

Recommendation

This guide strongly recommends editing and compiling ModelDesign files over direct editing of UANodeSet files. Although ModelDesign files are not part of the OPC UA standard (UANodeSet are part of the standard) they are part of the toolchain used by the OPC Foundation to generate official UANodeSet files. Following the example set by the OPC Foundation will result in a more sustainable, reproducible and stable workflow overall.

Install Visual Studio 2019

Info

An initial attempt with VS2017 failed. Use VS2019 or later.

Edit 2020-10-16: MS Visual Studio 2017 version 15.9.28, .NET framework version 4.8.04084 was reported to work in the comments.

Visual Studio Code can not compile solution projects without plugin. Prefer Visual Studio, which is a full IDE over Visual Studio Code, which is more of a featureful editor.

Install a recent version of Visual Studio Community Edition or better.

https://visualstudio.microsoft.com/de/downloads/

direct download link: https://visualstudio.microsoft.com/de/thank-you-downloading-visual-studio/?sku=Community

Follow the standard installation procedure.

Clone UA-ModelCompiler from Github

Note

You may use any Git-Client of your preference. This guide uses the official git command line client for windows (https://git-scm.com/download/win)

# johndoe@winpc MINGW64 /c/FLT_SW
git clone https://github.com/OPCFoundation/UA-ModelCompiler.git
cd UA-ModelCompiler
git checkout 8817477c7b481fd6eb6e9cccc05b76e83c7329ba
Notice Title

This commit was carefully chosen. It is the latest commit compatible with this tutorial. The master branch should be considered unstable.

Clone OPCFoundation UA-Nodeset submodule

UA-ModelCompiler uses the official OPC Foundation nodeset collection at https://github.com/OPCFoundation/UA-Nodeset as submodule. The ModelCompiler can be built without the submodule but having a rather complete collection of official UA-Nodesets available will come in handy when editing and compiling the ModelDesign file with Visual Studio 2019 later on.

To initialize the submodule, use the following command. This will also check out the referenced version:

# johndoe@winpc MINGW64 /c/FLT_SW/UA-ModelCompiler ((8817477...))
git submodule update --init --recursive

Open and compile UA-ModelCompiler with Visual Studio 2019

Start Visual Studio 2019

And open ModelCompiler Solution.sln from the folder created by git clone

You may get warning about unsupported or incompatible projects, as follows:

To fix this, you have to load both sub-projects of ModelCompiler Solution (see also https://developercommunity.visualstudio.com/content/problem/216061/project-incompatible-application-not-installed.html)

Configure the project to build in Release mode instead of the default Debug mode

You’re now ready to build UA-ModelCompiler. Watch the VS2019 output pane for success messages.

The output should look as follows:

1>------ Build started: Project: UA Core Library, Configuration: Release Any CPU ------
1>  UA Core Library -> C:\FLT_SW\UA-ModelCompiler\Bin\Release\Opc.Ua.ModelCompiler.Core.dll
2>------ Build started: Project: UA Model Compiler, Configuration: Release Any CPU ------
2>  UA Model Compiler -> C:\FLT_SW\UA-ModelCompiler\Bin\Release\Opc.Ua.ModelCompiler.exe
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The output shows, that the UA-ModelCompiler is stored at C:\FLT_SW\UA-ModelCompiler\Bin\Release\Opc.Ua.ModelCompiler.exe

Use PowerShell to execute Opc.Ua.ModelCompiler.exe without any arguments to get a small pop-up window with help information

# PS X:\>
cd C:\FLT_SW\UA-ModelCompiler\Bin\Release\

# PS C:\FLT_SW\UA-ModelCompiler\Bin\Release>
.\Opc.Ua.ModelCompiler.exe

The executable Opc.Ua.ModelCompiler.exe will be used to compile the OPC UA ModelDesign file to a OPC UA NodeSet and auxiliar files.

Published inInformation Modeling

2 Comments

  1. Marco D'Aurelio Marco D'Aurelio

    Hello,

    Many thanks for the comprehensive and detailed tutorial, I am finding it very useful in my journey into OPC UA.

    Just a notice: I was able to successfully compile UA-ModelCompiler with MS Visual Studio 2017 version 15.9.28, .NET framework version 4.8.04084.

    Best regards.

    • Benedict Simlinger Benedict Simlinger

      Thank you for your feedback. The post is updated accordingly.

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.