Skip to content

Commit 72ff881

Browse files
committed
Enable debugging of SmallSharp tasks via MSBuild property
Set DebugSmallSharp=true to get a debugger launched when SmallSharp is about to start VS integration.
1 parent 3585000 commit 72ff881

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/SmallSharp/MonitorActiveDocument.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ public class MonitorActiveDocument : Task
1818
[Required]
1919
public ITaskItem[] StartupFiles { get; set; } = Array.Empty<ITaskItem>();
2020

21+
public string? Debugger { get; set; }
22+
2123
public override bool Execute()
2224
{
25+
if (bool.TryParse(Debugger, out var debugger) && debugger)
26+
{
27+
System.Diagnostics.Debugger.Launch();
28+
}
29+
2330
if (string.IsNullOrEmpty(LaunchProfiles) ||
2431
string.IsNullOrEmpty(UserFile))
2532
{

src/SmallSharp/SmallSharp.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
<Target Name="MonitorActiveDocument" Condition="'$(BuildingInsideVisualStudio)' == 'true'" AfterTargets="CompileDesignTime" DependsOnTargets="CollectStartupFile">
3131
<MonitorActiveDocument LaunchProfiles="$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Properties', 'launchSettings.json'))"
3232
UserFile="$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(MSBuildProjectFile).user'))"
33-
StartupFiles="@(StartupFile)" />
33+
StartupFiles="@(StartupFile)"
34+
Debugger="$(DebugSmallSharp)"/>
3435
</Target>
3536

3637
<Target Name="StartupFile" BeforeTargets="BeforeCompile;CoreCompile;CompileDesignTime" DependsOnTargets="$(StartupFileDependsOn)" />

0 commit comments

Comments
 (0)