Skip to content

Commit

Permalink
Enable debugging of SmallSharp tasks via MSBuild property
Browse files Browse the repository at this point in the history
Set DebugSmallSharp=true to get a debugger launched when
SmallSharp is about to start VS integration.
  • Loading branch information
kzu committed Nov 16, 2022
1 parent 3585000 commit 72ff881
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/SmallSharp/MonitorActiveDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ public class MonitorActiveDocument : Task
[Required]
public ITaskItem[] StartupFiles { get; set; } = Array.Empty<ITaskItem>();

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))
{
Expand Down
3 changes: 2 additions & 1 deletion src/SmallSharp/SmallSharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<Target Name="MonitorActiveDocument" Condition="'$(BuildingInsideVisualStudio)' == 'true'" AfterTargets="CompileDesignTime" DependsOnTargets="CollectStartupFile">
<MonitorActiveDocument LaunchProfiles="$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', 'Properties', 'launchSettings.json'))"
UserFile="$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(MSBuildProjectFile).user'))"
StartupFiles="@(StartupFile)" />
StartupFiles="@(StartupFile)"
Debugger="$(DebugSmallSharp)"/>
</Target>

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

0 comments on commit 72ff881

Please sign in to comment.