Setting the solution configuration and platform

For automated processes, the active solution configuration must be explicitly set. The example iterates through all configurations of the solution and enables the desired platform.

For unattended scripts and CI/CD pipelines, you should also set dte.SuppressUI = true. This suppresses modal VS dialogs during automation. TcAutomationSettings.SilentMode is independent of this and suppresses TwinCAT-specific dialog boxes. For fully unattended processes, both should be enabled.

Requirements

C# sample

The iteration is performed over SolutionBuild.SolutionConfigurations. The desired configuration is identified by comparing PlatformName.

using EnvDTE;

// Iterate all solution configurations and activate target platform
SolutionConfigurations configs =
    solution.SolutionBuild.SolutionConfigurations as SolutionConfigurations;

foreach (SolutionConfiguration2 config in configs)
{
    if (config.PlatformName == "TwinCAT OS (x64)")
    {
        config.Activate();
        break;
    }
}

// SuppressUI: suppresses UI dialogs (recommended for automation)
dte.SuppressUI = true;
dte.MainWindow.Visible = false;
Setting the solution configuration and platform 1:

The available platform names depend on the installed TwinCAT version. The official TwinCAT Platform Matrix provides a complete overview of the supported target platforms (operating system, processor, PE/ELF format).