Skip to content

benhar-dev/ps-dte-errorlist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proof of concept PowerShell Script for Building TwinCAT Solutions via C# DTE to dte.ToolWindows.ErrorList.ErrorItems

Disclaimer

This guide is a personal project and not a peer-reviewed publication or sponsored document. It is provided “as is,” without any warranties—express or implied—including, but not limited to, accuracy, completeness, reliability, or suitability for any purpose. The author(s) shall not be held liable for any errors, omissions, delays, or damages arising from the use or display of this information.

All opinions expressed are solely those of the author(s) and do not necessarily represent those of any organization, employer, or other entity. Any assumptions or conclusions presented are subject to revision or rethinking at any time.

Use of this information, code, or scripts provided is at your own risk. Readers are encouraged to independently verify facts. This content does not constitute professional advice, and no client or advisory relationship is formed through its use.

Description

This repository provides a PowerShell script that bypasses the limitation of accessing dte.ToolWindows.ErrorList.ErrorItems. Instead of attempting a direct cast from DTE to DTE2, it uses embedded C# to create the DTE instance and retrieve build errors. Normal DTE operations remain fully supported.

Getting Started

Dependencies

  • Windows PowerShell 5.1 or PowerShell 7+ (must run with -STA).
  • TwinCAT XAE Shell installed, with:
    • EnvDTE.dll
    • EnvDTE80.dll
      Typically found under:
      C:\Program Files (x86)\Beckhoff\TcXaeShell\Common7\IDE\PublicAssemblies\
  • TwinCAT 3 Solution file (.sln) to build.

Configuration

Adjust the following variables in the script:

$SolutionPath = "$env:UserProfile\Desktop\ps-dte-errorlist\example\example.sln"
$ProgId       = "TcXaeShell.DTE.15.0"
$MakeVisible  = $true
$envDte       = "C:\Program Files (x86)\Beckhoff\TcXaeShell\Common7\IDE\PublicAssemblies\EnvDTE.dll"
$envDte80     = "C:\Program Files (x86)\Beckhoff\TcXaeShell\Common7\IDE\PublicAssemblies\EnvDTE80.dll"
  • $SolutionPath: Absolute path to your .sln file.
  • $ProgId: ProgID for the TwinCAT XAE shell. Adjust version as needed.
  • $MakeVisible: Set to $true to make the Visual Studio window visible during build.
  • $envDte / $envDte80: Paths to EnvDTE assemblies.

Installation

Clone or copy the script into your local environment. No package installation is required.

Usage

Run the script in an STA PowerShell session:

pwsh -STA -File .\Build-TwinCAT.ps1

The script will:

  1. Launch a new TwinCAT XAE instance (DTE).
  2. Open the configured .sln solution file.
  3. Trigger a build.
  4. Wait for build completion.
  5. Output build status:
    • Success → "Build succeeded."
    • Failure → Prints error list entries with file, line, column, and description.

About

Proof of concept PowerShell Script for Building TwinCAT Solutions via C# DTE to dte.ToolWindows.ErrorList.ErrorItems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors