Skip to content

Commit cf3b7af

Browse files
Add dotnet-dump as implicit requirement of DotNet SDK component
The dotnet-dump tool was not installed in Docker images, causing memory dump collection to fail silently on build timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e3f56a0 commit cf3b7af

5 files changed

Lines changed: 121 additions & 100 deletions

File tree

eng/docker/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ ENV PATH="C:\Program Files\dotnet;${PATH}"
6262
RUN & .\dotnet-install.ps1 -Version 9.0.310 -InstallDir 'C:\Program Files\dotnet'
6363

6464

65+
# .NET Dump Tool
66+
RUN dotnet tool install --global dotnet-dump;
67+
68+
6569
# Epilogue
6670
# Create directories for mountpoints
6771
ARG MOUNTPOINTS

eng/docker/Dockerfile.claude

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ ENV PATH="C:\Program Files\dotnet;${PATH}"
6262
RUN & .\dotnet-install.ps1 -Version 9.0.310 -InstallDir 'C:\Program Files\dotnet'
6363

6464

65+
# .NET Dump Tool
66+
RUN dotnet tool install --global dotnet-dump;
67+
68+
6569
# Install Node.js
6670
RUN Invoke-WebRequest -Uri "https://nodejs.org/dist/v22.0.0/node-v22.0.0-win-x64.zip" -OutFile node.zip; `
6771
Expand-Archive node.zip -DestinationPath C:\; `

eng/docker/Dockerfile.claude.win2022

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ ENV PATH="C:\Program Files\dotnet;${PATH}"
6262
RUN & .\dotnet-install.ps1 -Version 9.0.310 -InstallDir 'C:\Program Files\dotnet'
6363

6464

65+
# .NET Dump Tool
66+
RUN dotnet tool install --global dotnet-dump;
67+
68+
6569
# Install Node.js
6670
RUN Invoke-WebRequest -Uri "https://nodejs.org/dist/v22.0.0/node-v22.0.0-win-x64.zip" -OutFile node.zip; `
6771
Expand-Archive node.zip -DestinationPath C:\; `

eng/docker/Dockerfile.win2022

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ ENV PATH="C:\Program Files\dotnet;${PATH}"
6262
RUN & .\dotnet-install.ps1 -Version 9.0.310 -InstallDir 'C:\Program Files\dotnet'
6363

6464

65+
# .NET Dump Tool
66+
RUN dotnet tool install --global dotnet-dump;
67+
68+
6569
# Epilogue
6670
# Create directories for mountpoints
6771
ARG MOUNTPOINTS
Lines changed: 105 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,106 @@
1-
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2-
3-
using JetBrains.Annotations;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.IO;
7-
using System.Linq;
8-
9-
namespace PostSharp.Engineering.BuildTools.Docker;
10-
11-
[PublicAPI]
12-
public sealed class DotNetComponent : ContainerComponent
13-
{
14-
public string Version { get; }
15-
16-
public Version? ParsedVersion { get; }
17-
18-
public DotNetComponentKind DotNetComponentKind { get; }
19-
20-
public DotNetComponent( string version, DotNetComponentKind dotNetComponentKind )
21-
{
22-
this.Version = version;
23-
this.DotNetComponentKind = dotNetComponentKind;
24-
25-
var v = this.Version.Split( "-" )[0];
26-
27-
if ( System.Version.TryParse( v, out var parsedVersion ) )
28-
{
29-
this.ParsedVersion = parsedVersion;
30-
}
31-
}
32-
33-
public override string Name => $"Install .NET {this.DotNetComponentKind} {this.Version}";
34-
35-
public override string Key => $"{nameof(DotNetComponent)}:{this.DotNetComponentKind}:{this.Version}";
36-
37-
public override ContainerComponentKind Kind => ContainerComponentKind.DotNet;
38-
39-
public override void AddRequirements( IReadOnlyList<ContainerComponent> components, Action<ContainerComponent> add )
40-
{
41-
if ( !components.OfType<DotNetInstallerComponent>().Any() )
42-
{
43-
add( new DotNetInstallerComponent() );
44-
}
45-
}
46-
47-
public override void WriteDockerfile( TextWriter writer, ContainerOperatingSystem operatingSystem )
48-
{
49-
// Run script directly since we're already in a PowerShell shell
50-
if ( this.DotNetComponentKind == DotNetComponentKind.Sdk )
51-
{
52-
writer.WriteLine(
53-
$"""
54-
RUN & .\dotnet-install.ps1 -Version {this.Version} -InstallDir 'C:\Program Files\dotnet'
55-
""" );
56-
}
57-
else
58-
{
59-
var runtime = this.DotNetComponentKind switch
60-
{
61-
DotNetComponentKind.DotNetRuntime => "dotnet",
62-
DotNetComponentKind.WindowsDesktopRuntime => "windowsdesktop",
63-
DotNetComponentKind.AspNetCoreRuntime => "aspnetcore",
64-
_ => throw new InvalidOperationException()
65-
};
66-
67-
writer.WriteLine(
68-
$"""
69-
RUN & .\dotnet-install.ps1 -Version {this.Version} -Runtime {runtime} -InstallDir 'C:\Program Files\dotnet'
70-
""" );
71-
}
72-
}
73-
74-
public override string ToString() => $"{this.Kind} {this.DotNetComponentKind} {this.Version}";
75-
76-
public override int CompareTo( ContainerComponent? other )
77-
{
78-
var compareBase = base.CompareTo( other );
79-
80-
if ( compareBase != 0 )
81-
{
82-
return compareBase;
83-
}
84-
85-
var otherDotNetComponent = (DotNetComponent) other!;
86-
87-
// Compare the version number.
88-
if ( this.ParsedVersion != null && otherDotNetComponent.ParsedVersion != null )
89-
{
90-
var compareParsedVersion = this.ParsedVersion.CompareTo( otherDotNetComponent.ParsedVersion );
91-
92-
if ( compareParsedVersion != 0 )
93-
{
94-
return compareParsedVersion;
95-
}
96-
}
97-
98-
// Compare the string part of the version number.
99-
return -string.Compare( this.Version, otherDotNetComponent.Version, StringComparison.Ordinal );
100-
}
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using JetBrains.Annotations;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
9+
namespace PostSharp.Engineering.BuildTools.Docker;
10+
11+
[PublicAPI]
12+
public sealed class DotNetComponent : ContainerComponent
13+
{
14+
public string Version { get; }
15+
16+
public Version? ParsedVersion { get; }
17+
18+
public DotNetComponentKind DotNetComponentKind { get; }
19+
20+
public DotNetComponent( string version, DotNetComponentKind dotNetComponentKind )
21+
{
22+
this.Version = version;
23+
this.DotNetComponentKind = dotNetComponentKind;
24+
25+
var v = this.Version.Split( "-" )[0];
26+
27+
if ( System.Version.TryParse( v, out var parsedVersion ) )
28+
{
29+
this.ParsedVersion = parsedVersion;
30+
}
31+
}
32+
33+
public override string Name => $"Install .NET {this.DotNetComponentKind} {this.Version}";
34+
35+
public override string Key => $"{nameof(DotNetComponent)}:{this.DotNetComponentKind}:{this.Version}";
36+
37+
public override ContainerComponentKind Kind => ContainerComponentKind.DotNet;
38+
39+
public override void AddRequirements( IReadOnlyList<ContainerComponent> components, Action<ContainerComponent> add )
40+
{
41+
if ( !components.OfType<DotNetInstallerComponent>().Any() )
42+
{
43+
add( new DotNetInstallerComponent() );
44+
}
45+
46+
if ( this.DotNetComponentKind == DotNetComponentKind.Sdk && !components.OfType<DotNetDumpComponent>().Any() )
47+
{
48+
add( new DotNetDumpComponent() );
49+
}
50+
}
51+
52+
public override void WriteDockerfile( TextWriter writer, ContainerOperatingSystem operatingSystem )
53+
{
54+
// Run script directly since we're already in a PowerShell shell
55+
if ( this.DotNetComponentKind == DotNetComponentKind.Sdk )
56+
{
57+
writer.WriteLine(
58+
$"""
59+
RUN & .\dotnet-install.ps1 -Version {this.Version} -InstallDir 'C:\Program Files\dotnet'
60+
""" );
61+
}
62+
else
63+
{
64+
var runtime = this.DotNetComponentKind switch
65+
{
66+
DotNetComponentKind.DotNetRuntime => "dotnet",
67+
DotNetComponentKind.WindowsDesktopRuntime => "windowsdesktop",
68+
DotNetComponentKind.AspNetCoreRuntime => "aspnetcore",
69+
_ => throw new InvalidOperationException()
70+
};
71+
72+
writer.WriteLine(
73+
$"""
74+
RUN & .\dotnet-install.ps1 -Version {this.Version} -Runtime {runtime} -InstallDir 'C:\Program Files\dotnet'
75+
""" );
76+
}
77+
}
78+
79+
public override string ToString() => $"{this.Kind} {this.DotNetComponentKind} {this.Version}";
80+
81+
public override int CompareTo( ContainerComponent? other )
82+
{
83+
var compareBase = base.CompareTo( other );
84+
85+
if ( compareBase != 0 )
86+
{
87+
return compareBase;
88+
}
89+
90+
var otherDotNetComponent = (DotNetComponent) other!;
91+
92+
// Compare the version number.
93+
if ( this.ParsedVersion != null && otherDotNetComponent.ParsedVersion != null )
94+
{
95+
var compareParsedVersion = this.ParsedVersion.CompareTo( otherDotNetComponent.ParsedVersion );
96+
97+
if ( compareParsedVersion != 0 )
98+
{
99+
return compareParsedVersion;
100+
}
101+
}
102+
103+
// Compare the string part of the version number.
104+
return -string.Compare( this.Version, otherDotNetComponent.Version, StringComparison.Ordinal );
105+
}
101106
}

0 commit comments

Comments
 (0)