Build on a system without MATLAB® (Build Agent)

If you want to build your TwinCAT objects on a development system without MATLAB® installation, e.g. using a build agent, you can use the so-called Pack-and-go feature (Pack'N Go) from MathWorks®. The TwinCAT Target for Simulink® supports and extends this feature for TwinCAT development processes.

Pack’N Go

The Pack'N Go feature allows you to pack a project and all its dependencies. This makes it easier to transfer the project to different systems where it can be compiled. The original MATLAB® or TwinCAT environments are not required for this. Such a pack can be particularly advantageous in a CI context, as it enables more efficient use of MATLAB® agents.

Creating a pack output

Sample

TwinCAT.ModuleGenerator.Settings.Change('ConfigurationLevel', 'Advanced');
modelName = 'SimpleTempCtrl';
open_system(modelName);

TwinCAT.ModuleGenerator.Simulink.ModelExportConfig.ShowModelParam(modelName,'SolverType','Fixed-step');
TwinCAT.ModuleGenerator.Simulink.ModelExportConfig.ShowModelParam(modelName,'SystemTargetFile','TwinCatGrt.tlc'); 
% add your custom settings here
TwinCAT.ModuleGenerator.Simulink.ModelExportConfig.ShowModelParam(modelName,'TcProject_Publish', false); % disable publish step
TwinCAT.ModuleGenerator.Simulink.ModelExportConfig.ShowModelParam(modelName,'TcProject_PackOutputPath', fullfile(pwd,'simpleTempCtrl.zip')); % define name of pack output (also non zip is allowed 'simpleTempCtrlPack'

slbuild(modelName); % create pack output (without building)

Sample in MATLAB®: TwinCAT.ModuleGenerator.Samples.Start("Use Continuous Integration Principles with Code Generation").

Build

Once you have created a pack output, e.g. 'simpleTempCtrl.zip', you can copy this file to another Build system. The Build system then only requires TwinCAT XAE and Visual Studio Professional or an equivalent program (no TwinCAT Target and no MATLAB® installation). For TwinCAT Build 4026, install on the build agent:

Unpack the pack output on the build agent and navigate to the vcxproj file. You can open the file from here in Visual Studio to build the project. You can also add the project as an existing element to your TwinCAT Solution (in the TwinCAT C++ area), or build the project via the msbuild command line interface (see first line in all PublishLog.txt files for reference).