From 72ff8811360d326f4a3d3b61c3e01d015d1a80ee Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Wed, 16 Nov 2022 13:45:20 -0300 Subject: [PATCH] Enable debugging of SmallSharp tasks via MSBuild property Set DebugSmallSharp=true to get a debugger launched when SmallSharp is about to start VS integration. --- src/SmallSharp/MonitorActiveDocument.cs | 7 +++++++ src/SmallSharp/SmallSharp.targets | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SmallSharp/MonitorActiveDocument.cs b/src/SmallSharp/MonitorActiveDocument.cs index 51c63ed..9572a7e 100644 --- a/src/SmallSharp/MonitorActiveDocument.cs +++ b/src/SmallSharp/MonitorActiveDocument.cs @@ -18,8 +18,15 @@ public class MonitorActiveDocument : Task [Required] public ITaskItem[] StartupFiles { get; set; } = Array.Empty(); + public string? Debugger { get; set; } + public override bool Execute() { + if (bool.TryParse(Debugger, out var debugger) && debugger) + { + System.Diagnostics.Debugger.Launch(); + } + if (string.IsNullOrEmpty(LaunchProfiles) || string.IsNullOrEmpty(UserFile)) { diff --git a/src/SmallSharp/SmallSharp.targets b/src/SmallSharp/SmallSharp.targets index 55afc25..cdc7ac4 100644 --- a/src/SmallSharp/SmallSharp.targets +++ b/src/SmallSharp/SmallSharp.targets @@ -30,7 +30,8 @@ + StartupFiles="@(StartupFile)" + Debugger="$(DebugSmallSharp)"/>