Selecting projects for the build process

The Visual Studio API provides all the necessary mechanisms for selecting projects for a solution configuration. The required methods are part of the SolutionBuild2 class in the EnvDTE namespace. BuildProject requires the full path to the project file and the build configuration. The full path may point to .tsproj or .plcproj. If the third parameter is $true, the call blocks until completion.

$sln = $dte.Solution
$prj = $dte.Projects.Item(1) #SysMan Project
$sysManProjectName = $prj.FullName
$plcPrjProjectName = PathToPlcProjFile
$sln.SolutionBuild.BuildProject("Release|TwinCAT RT (x64)",$sysManProjectName,$true)
$sln.SolutionBuild.BuildProject("Release|TwinCAT RT (x64)",$plcPrjProjectName,$true)

The placeholder PathToPlcProjFile represents the full path to a *.plcproj file that represents a TwinCAT 3 PLC project.

Selecting projects for the build process 1:

The build configuration (first parameter) specifies the target platform, for example, TwinCAT RT (x64). The official TwinCAT Platform Matrix provides a complete overview of the supported target platforms (operating system, processor, PE/ELF format).