2

I am aware that code is optimized when built in release mode and should always be deployed to production as such, but I wanted to know if there was a way to find out if your code has been deployed with a debug build vs. a release build.

Would a PowerShell cmdlet be a potential route for this type of query?

Karl Anderson
  • 34,606
  • 12
  • 65
  • 80

1 Answers1

2

Try a function like this:

function Test-DebugAssembly($path) {
     $assembly = [Reflection.Assembly]::LoadFile("$path")
     $attr = $assembly.GetCustomAttributes([Diagnostics.DebuggableAttribute], $false)
     if (!$attr) { 
         $false 
     }
     else {
         $attr.IsJITTrackingEnabled
     }
 }
Keith Hill
  • 194,368
  • 42
  • 353
  • 369