Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
44b7d65
POC
jamescrosswell Oct 9, 2024
157a4a9
Configurable level
jamescrosswell Oct 9, 2024
67a1c38
Changed dependency from net5.0 to net6.0
jamescrosswell Oct 9, 2024
4f8f917
Format code
getsentry-bot Oct 9, 2024
0d1aa2d
Update MemoryMonitor.cs
jamescrosswell Oct 9, 2024
5ceff11
Exclude on Android and iOS
jamescrosswell Oct 10, 2024
ae55ae9
Bundle dotnet-gcdump in the Sentry nuget package
jamescrosswell Oct 10, 2024
c5b75ad
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 10, 2024
60aeda0
Format code
getsentry-bot Oct 11, 2024
cc1a00e
Fixed Bindable tests
jamescrosswell Oct 11, 2024
b02fa28
Update CHANGELOG.md
jamescrosswell Oct 11, 2024
0625662
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 11, 2024
1d12b7c
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell Oct 11, 2024
ecfbce3
Update CHANGELOG.md
jamescrosswell Oct 11, 2024
1e6d29b
Tweaked the demos
jamescrosswell Oct 11, 2024
5b0f08e
Revert "Bundle dotnet-gcdump in the Sentry nuget package"
jamescrosswell Oct 13, 2024
ba4bcd9
Unbundled GCDump from NuGet package
jamescrosswell Oct 13, 2024
a357e9f
Switched to built in GC.RegisterForFullGCNotification events for garb…
jamescrosswell Oct 14, 2024
b6c3bff
Tweaked settings to expedite full GC in Heap Dump sample
jamescrosswell Oct 14, 2024
e36dfef
Added TryGetDumpLocation tests
jamescrosswell Oct 15, 2024
d35477b
Added CaptureMemoryDump tests
jamescrosswell Oct 15, 2024
4c0ccc8
Refactored MemoryMonitor to use triggers and debouncers
jamescrosswell Oct 15, 2024
ffad135
Format code
getsentry-bot Oct 15, 2024
265e397
Fixed tests
jamescrosswell Oct 15, 2024
7a3b109
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 15, 2024
da07de2
Format code
getsentry-bot Oct 15, 2024
975b9b1
Added CheckMemoryUsage tests
jamescrosswell Oct 15, 2024
38ad7bc
Fixed remaining BindableOptions tests
jamescrosswell Oct 15, 2024
ef3a33f
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 15, 2024
4b86619
Bundle dotnet-gcdump in Sentry.nupkg
jamescrosswell Oct 17, 2024
08c9db4
Use bundled version of gcdump if it is present
jamescrosswell Oct 17, 2024
169ef49
Delete buildlog.txt
jamescrosswell Oct 17, 2024
2e6a0f1
Review feedback
jamescrosswell Oct 23, 2024
87b76d8
Refactored error handling on garbage collection monitor to use a Cont…
jamescrosswell Oct 23, 2024
3f15073
Comment in Dispose
jamescrosswell Oct 23, 2024
2dfd4f4
Review feedback
jamescrosswell Oct 23, 2024
99af671
Use _options.FileSystem
jamescrosswell Oct 23, 2024
acf93ab
Type
jamescrosswell Oct 23, 2024
8708377
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell Oct 23, 2024
3b62d53
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 23, 2024
2a3d8b7
GCDump.props now downloads nuget directly, rather than installing dot…
jamescrosswell Oct 23, 2024
3eb2f73
Created separate demo and tweaked the API
jamescrosswell Oct 23, 2024
60f0b7e
Format code
getsentry-bot Oct 23, 2024
70486da
Typo in transitive build file
jamescrosswell Oct 23, 2024
d2755db
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell Oct 23, 2024
8133a63
Updated solution filters
jamescrosswell Oct 23, 2024
58d9e55
Reverted to Continuation to handle errors in the gc monitor
jamescrosswell Oct 23, 2024
7135767
Review feedback
jamescrosswell Oct 28, 2024
22760c8
Update SentrySdk.cs
jamescrosswell Oct 28, 2024
f371304
Update Directory.Build.props
jamescrosswell Oct 28, 2024
26c85b8
release: 14.12.1-dump1
getsentry-bot Oct 28, 2024
0142d29
Workaround issue in release action
jamescrosswell Oct 28, 2024
8a831fc
Revert "Workaround issue in release action"
jamescrosswell Oct 28, 2024
056ec48
Merge branch 'release/14.12.1-dump1' into auto-heap-dump
Oct 28, 2024
29058f1
Revert "Merge branch 'release/14.12.1-dump1' into auto-heap-dump"
jamescrosswell Oct 29, 2024
5469815
Review feedback
jamescrosswell Nov 4, 2024
f1c9e64
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell Nov 4, 2024
8a49c01
Update ApiApprovalTests.Run.DotNet9_0.verified.txt
jamescrosswell Nov 4, 2024
dbe9f60
Update action.yml
jamescrosswell Nov 4, 2024
be63db4
Revert "Update action.yml"
jamescrosswell Nov 4, 2024
36e4a2b
Update workaround for slow release builds for ios
jamescrosswell Nov 6, 2024
076e9f9
Removed async void unit tests
jamescrosswell Nov 6, 2024
506fba1
Drop net6.0 target from Sentry.Tests
jamescrosswell Nov 6, 2024
298f57c
Add diagnostic logging for Windows tests
jamescrosswell Nov 6, 2024
a234ef2
Update build.yml
jamescrosswell Nov 6, 2024
f4fba3a
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell Nov 7, 2024
4eafc16
Disabled diagnostics output on windows tests
jamescrosswell Nov 7, 2024
a09ffef
Update build.yml
jamescrosswell Nov 7, 2024
b8cffed
Use mock GC implementation for MemoryMonitorTests
jamescrosswell Nov 9, 2024
b216a3c
Update Sentry.Tests.csproj
jamescrosswell Nov 9, 2024
e1ba7c2
Try disabling heapdump tests on Windows in CI
jamescrosswell Nov 10, 2024
2c79a4a
Reverse skip condition
jamescrosswell Nov 10, 2024
72c90b5
Try re-enabling GarbageCollectionMonitorTests on Windows
jamescrosswell Nov 11, 2024
cadd0cf
Try reinstating MemoryMonitorTests (constructor test changed)
jamescrosswell Nov 11, 2024
84c436f
Update MemoryMonitor.cs
jamescrosswell Nov 11, 2024
3a9ba29
Refactored Constructor_NoHeapdumpsConfigured_Throws
jamescrosswell Nov 11, 2024
9fea039
Try re-enabling remaining MemoryMonitorTests
jamescrosswell Nov 11, 2024
845378c
Re-enable remaining MemoryMonitorTests
jamescrosswell Nov 11, 2024
4245a75
Unbundled dotnet-gcdump
jamescrosswell Nov 11, 2024
5865245
Disable CaptureMemoryDump and TryGetDumpLocation tests
jamescrosswell Nov 11, 2024
d9b9306
Re-enable CaptureMemoryDump tests
jamescrosswell Nov 11, 2024
13bfe6f
Disable CaptureMemoryDump and enable TryGetDumpLocation
jamescrosswell Nov 11, 2024
d330c2c
Fixed CaptureMemoryDump_CapturesDump
jamescrosswell Nov 11, 2024
8127bb5
Added remarks about dotnet-gcdump dependency to options
jamescrosswell Nov 11, 2024
e628bb3
Merge branch 'version-5.0.0' into auto-heap-dump
bruno-garcia Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- `SentryOptions.EnableTracing` has been removed. Instead, tracing should be enabled or disabled by setting the `SentryOptions.TracesSampleRate` or by using `SentryOptions.TracesSampler` to configure a sampling function ([#3569](https://github.com/getsentry/sentry-dotnet/pull/3569))
- The `FailedRequestTargets`, `TagFilters` and `TracePropagationTargets` options have all been changed from `SubstringOrRegexPattern` to `IList<StringOrRegex>` ([#3566](https://github.com/getsentry/sentry-dotnet/pull/3566))
- `Scope.Transaction` is now always stored as an `AsyncLocal` also in [Global Mode](https://docs.sentry.io/platforms/dotnet/configuration/options/#is-global-mode-enabled), to prevent auto-instrumented spans from the UI ending up parented to transactions from a background task (or vice versa). ([#3596](https://github.com/getsentry/sentry-dotnet/pull/3596))
- Heap dumps can be captured automatically when memory usage exceeds a configurable threshold ([#3667](https://github.com/getsentry/sentry-dotnet/pull/3667))

## Unreleased
## 4.12.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<VersionPrefix>4.12.1</VersionPrefix>
<VersionPrefix>4.12.2-alpha</VersionPrefix>
<LangVersion>12</LangVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
1 change: 1 addition & 0 deletions Sentry.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QL/@EntryIndexedValue">QL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=debouncer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Enricher/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=enrichers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=instrumenter/@EntryIndexedValue">True</s:Boolean>
Expand Down
156 changes: 113 additions & 43 deletions samples/Sentry.Samples.Console.Basic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* - Performance Tracing (Transactions / Spans)
* - Release Health (Sessions)
* - MSBuild integration for Source Context (see the csproj)
* - Heap Dumps (.NET 6.0 or later)
*
* For more advanced features of the SDK, see Sentry.Samples.Console.Customized.
*/
Expand All @@ -12,6 +13,8 @@

using System.Net.Http;

CancellationTokenSource cts = new();

SentrySdk.Init(options =>
{
// You can set here in code, or you can set it in the SENTRY_DSN environment variable.
Expand All @@ -33,66 +36,133 @@

// This option tells Sentry to capture 100% of traces. You still need to start transactions and spans.
options.TracesSampleRate = 1.0;
});

// This starts a new transaction and attaches it to the scope.
var transaction = SentrySdk.StartTransaction("Program Main", "function");
SentrySdk.ConfigureScope(scope => scope.Transaction = transaction);
#if NET6_0_OR_GREATER
// This option tells Sentry to capture a heap dump when the process uses more than 5% of the total memory. The heap
// dump will be sent to Sentry as a file attachment.
options.EnableHeapDumps(5);

// This determines the level of heap dump events that are sent to Sentry
options.HeapDumpEventLevel = SentryLevel.Warning;

// Do some work. (This is where you'd have your own application logic.)
await FirstFunction();
await SecondFunction();
await ThirdFunction();
// A debouncer can be configured to tell Sentry how frequently to send heap dumps. In this case we've configured it
// to capture a maximum of 3 events per day and to wait at least 1 hour between each event.
options.HeapDumpDebouncer = Debouncer.PerDay(3, TimeSpan.FromHours(1));

// Always try to finish the transaction successfully.
// Unhandled exceptions will fail the transaction automatically.
// Optionally, you can try/catch the exception, and call transaction.Finish(exception) on failure.
transaction.Finish();
// This is an example of intercepting events before they get sent to Sentry. Typically, you might use this to
// filter events that you didn't want to send but in this case we're using it to detect when a heap dump has
// been captured, so we know when to stop allocating memory in the heap dump demo.
options.SetBeforeSend((evt, hint) =>
{
cts.Cancel();
return evt; // If we returned null here, that would stop the event from being sent
});
#endif
});

async Task FirstFunction()
#if NET6_0_OR_GREATER
await Task.Delay(1000);
Console.WriteLine();
Console.WriteLine("Choose a demo:");
Console.WriteLine("1. Tracing");
Console.WriteLine("2. Heap Dump");
Console.WriteLine("... or press any other key to quit.");
switch (Console.ReadKey().KeyChar)
{
// This is an example of making an HttpRequest. A trace us automatically captured by Sentry for this.
var messageHandler = new SentryHttpMessageHandler();
var httpClient = new HttpClient(messageHandler, true);
var html = await httpClient.GetStringAsync("https://example.com/");
Console.WriteLine(html);
case '1':
await TracingDemo();
break;
case '2':
await HeapDumpDemo(cts.Token);
break;
}
#else
await TracingDemo();
#endif

async Task SecondFunction()
async Task TracingDemo()
{
var span = transaction.StartChild("function", nameof(SecondFunction));
// This starts a new transaction and attaches it to the scope.
var transaction = SentrySdk.StartTransaction("Program Main", "function");
SentrySdk.ConfigureScope(scope => scope.Transaction = transaction);

try
{
// Simulate doing some work
await Task.Delay(100);
// Do some work. (This is where you'd have your own application logic.)
await FirstFunction();
await SecondFunction();
await ThirdFunction();

// Always try to finish the transaction successfully.
// Unhandled exceptions will fail the transaction automatically.
// Optionally, you can try/catch the exception, and call transaction.Finish(exception) on failure.
transaction.Finish();

// Throw an exception
throw new ApplicationException("Something happened!");
async Task FirstFunction()
{
// This is an example of making an HttpRequest. A trace us automatically captured by Sentry for this.
var messageHandler = new SentryHttpMessageHandler();
var httpClient = new HttpClient(messageHandler, true);
var html = await httpClient.GetStringAsync("https://example.com/");
Console.WriteLine(html);
}
catch (Exception exception)

async Task SecondFunction()
{
// This is an example of capturing a handled exception.
SentrySdk.CaptureException(exception);
span.Finish(exception);
var span = transaction.StartChild("function", nameof(SecondFunction));

try
{
// Simulate doing some work
await Task.Delay(100);

// Throw an exception
throw new ApplicationException("Something happened!");
}
catch (Exception exception)
{
// This is an example of capturing a handled exception.
SentrySdk.CaptureException(exception);
span.Finish(exception);
}

span.Finish();
}

span.Finish();
async Task ThirdFunction()
{
var span = transaction.StartChild("function", nameof(ThirdFunction));
try
{
// Simulate doing some work
await Task.Delay(100);

// This is an example of an unhandled exception. It will be captured automatically.
throw new InvalidOperationException("Something happened that crashed the app!");
}
finally
{
span.Finish();
}
}
}

async Task ThirdFunction()
// Heap dumps are only supported in .NET 6.0 or later.
#if NET6_0_OR_GREATER
async Task HeapDumpDemo(CancellationToken cancellationToken)
{
var span = transaction.StartChild("function", nameof(ThirdFunction));
try
var memoryHog = new List<byte[]>();
Console.WriteLine();
Console.WriteLine("Hogging memory...");

// Sentry checks memory usage every time a full garbage collection occurs. It might take a while to trigger this,
// although we've configured some ridiculously aggressive settings in the runtimeconfig.template.json file to make
// this happen more quickly, for the purposes of this demo... definitely don't do this in production!
while (cancellationToken.IsCancellationRequested == false)
{
// Simulate doing some work
await Task.Delay(100);

// This is an example of an unhandled exception. It will be captured automatically.
throw new InvalidOperationException("Something happened that crashed the app!");
}
finally
{
span.Finish();
var array = new byte[2_000_000_000];
array.Initialize();
memoryHog.Add(array);
}
GC.KeepAlive(memoryHog);
await Task.CompletedTask;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net6.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net8'))">
<PublishAot>true</PublishAot>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"configProperties": {
"System.GC.ConserveMemory": 9,
"System.GC.HighMemoryPercent": 20
}
}
6 changes: 6 additions & 0 deletions src/Sentry/BindableSentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ internal partial class BindableSentryOptions
public string? Environment { get; set; }
public string? Dsn { get; set; }
public int? MaxQueueItems { get; set; }
#if NET6_0_OR_GREATER && !(IOS || ANDROID)
public SentryLevel? HeapDumpEventLevel { get; set; }
#endif
public int? MaxCacheItems { get; set; }
public TimeSpan? ShutdownTimeout { get; set; }
public TimeSpan? FlushTimeout { get; set; }
Expand Down Expand Up @@ -68,6 +71,9 @@ public void ApplyTo(SentryOptions options)
options.Environment = Environment ?? options.Environment;
options.Dsn = Dsn ?? options.Dsn;
options.MaxQueueItems = MaxQueueItems ?? options.MaxQueueItems;
#if NET6_0_OR_GREATER && !(IOS || ANDROID)
options.HeapDumpEventLevel = HeapDumpEventLevel ?? options.HeapDumpEventLevel;
#endif
options.MaxCacheItems = MaxCacheItems ?? options.MaxCacheItems;
options.ShutdownTimeout = ShutdownTimeout ?? options.ShutdownTimeout;
options.FlushTimeout = FlushTimeout ?? options.FlushTimeout;
Expand Down
108 changes: 108 additions & 0 deletions src/Sentry/Debouncer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
namespace Sentry;

/// <summary>
/// A debouncer that can be used to limit the number of occurrences of an event within a given interval and optionally,
/// enforce a minimum cooldown period between events.
/// </summary>
public class Debouncer
{
internal enum DebouncerInterval { Minute, Hour, Day, ApplicationLifetime }

internal DateTimeOffset _intervalStart = DateTimeOffset.MinValue;
internal DateTimeOffset _lastEvent = DateTimeOffset.MinValue;
internal int _occurrences;

internal readonly DebouncerInterval _intervalType;
internal readonly int _eventMaximum;
private readonly TimeSpan? _cooldown;

private Debouncer(DebouncerInterval intervalType, int eventMaximum = 1, TimeSpan? cooldown = null)
{
_intervalType = intervalType;
_cooldown = cooldown;
_eventMaximum = eventMaximum;
}

/// <summary>
/// Creates a debouncer that limits the number of events per minute
/// </summary>
/// <param name="eventMaximum">The maximum number of events that will be processed per minute</param>
/// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param>
/// <returns></returns>
public static Debouncer PerMinute(int eventMaximum = 1, TimeSpan? cooldown = null)
=> new(DebouncerInterval.Minute, eventMaximum, cooldown);

/// <summary>
/// Creates a debouncer that limits the number of events per hour
/// </summary>
/// <param name="eventMaximum">The maximum number of events that will be processed per hour</param>
/// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param>
/// <returns></returns>
public static Debouncer PerHour(int eventMaximum = 1, TimeSpan? cooldown = null)
=> new(DebouncerInterval.Hour, eventMaximum, cooldown);

/// <summary>
/// Creates a debouncer that limits the number of events per day
/// </summary>
/// <param name="eventMaximum">The maximum number of events that will be processed per day</param>
/// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param>
/// <returns></returns>
public static Debouncer PerDay(int eventMaximum = 1, TimeSpan? cooldown = null)
=> new(DebouncerInterval.Day, eventMaximum, cooldown);

/// <summary>
/// Creates a debouncer that limits the number of events that will be processed for the lifetime of the application
/// </summary>
/// <param name="eventMaximum">The maximum number of events that will be processed</param>
/// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param>
/// <returns></returns>
public static Debouncer PerApplicationLifetime(int eventMaximum = 1, TimeSpan? cooldown = null)
=> new(DebouncerInterval.ApplicationLifetime, eventMaximum, cooldown);

private TimeSpan IntervalTimeSpan()
{
switch (_intervalType)
{
case DebouncerInterval.Minute:
return TimeSpan.FromMinutes(1);
case DebouncerInterval.Hour:
return TimeSpan.FromHours(1);
case DebouncerInterval.Day:
return TimeSpan.FromDays(1);
case DebouncerInterval.ApplicationLifetime:
return TimeSpan.MaxValue;
default:
throw new ArgumentOutOfRangeException(nameof(_intervalType));
}
}

internal void RecordOccurence(DateTimeOffset? timestamp = null)
{
var eventTime = timestamp ?? DateTimeOffset.UtcNow;

if (eventTime - _intervalStart >= IntervalTimeSpan())
{
_intervalStart = eventTime;
_occurrences = 0;
}

_occurrences++;
_lastEvent = eventTime;
}

internal bool CanProcess(DateTimeOffset? timestamp = null)
{
if (_occurrences >= _eventMaximum)
{
return false;
}

var eventTime = timestamp ?? DateTimeOffset.UtcNow;
if (_cooldown is { } cooldown && _lastEvent + cooldown > eventTime)
{
return false;
}

return true;
}
}
30 changes: 30 additions & 0 deletions src/Sentry/GCDump.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project>
<!-- Check if we're building for a target framework that supports dotnet-gcdump -->
<PropertyGroup>
<PlatformIsLegacy Condition="$(TargetFramework.StartsWith('net4')) or $(TargetFramework.StartsWith('netstandard'))">true</PlatformIsLegacy>
<PlatformIsMobile Condition="$(TargetFramework.EndsWith('android')) or $(TargetFramework.EndsWith('ios')) or $(TargetFramework.EndsWith('maccatalyst'))">true</PlatformIsMobile>
<PlatformSupportsGcDump Condition="!($(PlatformIsLegacy) == 'true' or $(PlatformIsMobile) == 'true')">true</PlatformSupportsGcDump>

<GCDumpVersion>8.0.547301</GCDumpVersion>
<GCDumpRootDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\tools\gcdump\'))</GCDumpRootDirectory>
<GCDumpTempDirectory>$(GCDumpRootDirectory)$(GCDumpVersion)\</GCDumpTempDirectory>
<!-- This is just where the relevant files are stored in the dotnet-gcdump Nuget package -->
<GCDumpIncludeFiles>$(GCDumpTempDirectory).store\dotnet-gcdump\$(GCDumpVersion)\dotnet-gcdump\$(GCDumpVersion)\tools\net6.0\any\</GCDumpIncludeFiles>
</PropertyGroup>

<Target Name="DownloadGCDump" BeforeTargets="CollectPackageReferences" Condition="'$(PlatformSupportsGcDump)' == 'true'">
<Message Importance="normal" Text="Found dotnet-gcdump - skipping download... " Condition="Exists('$(GCDumpIncludeFiles)')" />
<Message Importance="normal" Text="dotnet-gcdump not found... downloading to $(GCDumpTempDirectory)" Condition="!Exists('$(GCDumpIncludeFiles)')" />

<!-- NuGet doesn't have any "download" functionality, so we'll install it locally to a temporary folder -->
<Exec Command="dotnet tool install dotnet-gcdump --version $(GCDumpVersion) --tool-path $(GCDumpTempDirectory)" Condition="!Exists('$(GCDumpIncludeFiles)')" IgnoreExitCode="true" />

<Message Importance="high" Text="Unable to locate dotnet-gcdump files after install : $(GCDumpIncludeFiles)" Condition="!Exists('$(GCDumpIncludeFiles)')" />
</Target>

<!-- Include GCDump in the Sentry Nuget package. -->
<ItemGroup Condition="'$(PlatformSupportsGcDump)' == 'true'">
<None Include="$(GCDumpIncludeFiles)**" Pack="true" PackagePath="tools\dotnet-gcdump\" />
</ItemGroup>

</Project>
Loading
Loading