If you want to test if you’re currently debugging an SSIS package via BIDS/Visual Studio, or running normally via DTExec, you can use the following utility functions inside a Script task.
Public Function SSIS_IsBIDS() As Boolean
Return (SSIS_Environment() = "DtsDebugHost")
End Function
Public Function SSIS_IsDTExec() As Boolean
Return (SSIS_Environment() = "DTExec")
End Function
Public Function SSIS_Environment() As String
Return System.Diagnostics.Process.GetCurrentProcess.ProcessName.ToString
End Function