Skip to content

Commit 6cb96ed

Browse files
committed
Allow adding extra assemblies
1 parent 5be9171 commit 6cb96ed

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

Runner/Helpers/NuGetClient.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ async Task<List<PackageDependency>> FetchAsync()
433433
/// Resolves all transitive dependencies of a package for the given TFM.
434434
/// Returns null if any dependency has a non-permissive license.
435435
/// </summary>
436-
public async Task<Dictionary<string, string>?> ResolveAllDependenciesAsync(string rootId, string rootVersion, string targetTfm)
436+
public async Task<Dictionary<string, string>?> ResolveAllDependenciesAsync(string rootId, string rootVersion, string targetTfm, bool skipLicenseCheck = false)
437437
{
438438
var resolved = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
439439
var visited = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { rootId };
@@ -451,9 +451,12 @@ async Task<List<PackageDependency>> FetchAsync()
451451
string? version = await ResolveLatestVersionAsync(depId);
452452
if (version is null) continue;
453453

454-
string? license = await GetLicenseExpressionAsync(depId, version);
455-
if (!IsPermissiveLicense(license))
456-
return null;
454+
if (!skipLicenseCheck)
455+
{
456+
string? license = await GetLicenseExpressionAsync(depId, version);
457+
if (!IsPermissiveLicense(license))
458+
return null;
459+
}
457460

458461
resolved[depId] = version;
459462

Runner/Jobs/NuGetExtraAssembliesJob.cs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ internal sealed class NuGetExtraAssembliesJob : JobBase
1212

1313
public NuGetExtraAssembliesJob(HttpClient client, Dictionary<string, string> metadata) : base(client, metadata) { }
1414

15+
private static HashSet<string> ExtraPackages { get; } = new(
16+
[
17+
"SixLabors.ImageSharp", "SixLabors.Fonts", "SixLabors.ImageSharp.Drawing",
18+
"dnlib", "AsmResolver", "BepuPhysics",
19+
],
20+
StringComparer.OrdinalIgnoreCase);
21+
1522
protected override async Task RunJobCoreAsync()
1623
{
1724
await ChangeWorkingDirectoryToRamOrFastestDiskAsync();
@@ -58,6 +65,21 @@ private async Task BuildRuntimeAsync()
5865
var packages = await _nuget.SearchTopPackagesAsync(count);
5966
await LogAsync($"Found {packages.Count} packages to evaluate");
6067

68+
// Merge in ExtraPackages, resolving their latest versions and deduplicating
69+
var existingIds = new HashSet<string>(packages.Select(p => p.Id), StringComparer.OrdinalIgnoreCase);
70+
foreach (string extraId in ExtraPackages)
71+
{
72+
if (!existingIds.Add(extraId))
73+
continue;
74+
75+
string? version = await _nuget.ResolveLatestVersionAsync(extraId);
76+
if (version is not null)
77+
{
78+
packages.Add((extraId, version));
79+
await LogAsync($"Added extra package {extraId} {version}");
80+
}
81+
}
82+
6183
int skippedLicense = 0, skippedNoDlls = 0;
6284

6385
string packagesDir = "nuget-packages-temp";
@@ -71,12 +93,16 @@ private async Task BuildRuntimeAsync()
7193
string prefix = $"[NuGet {i + 1}/{packages.Count}] {id} {version}";
7294
LastProgressSummary = $"Checking NuGet package {i + 1}/{packages.Count}. Approved {approvedPackages.Count} so far.";
7395

74-
string? license = await _nuget.GetLicenseExpressionAsync(id, version);
75-
if (!NuGetClient.IsPermissiveLicense(license))
96+
bool isExtra = ExtraPackages.Contains(id);
97+
if (!isExtra)
7698
{
77-
await LogAsync($"{prefix} - skipped (license: {license ?? "none"})");
78-
skippedLicense++;
79-
continue;
99+
string? license = await _nuget.GetLicenseExpressionAsync(id, version);
100+
if (!NuGetClient.IsPermissiveLicense(license))
101+
{
102+
await LogAsync($"{prefix} - skipped (license: {license ?? "none"})");
103+
skippedLicense++;
104+
continue;
105+
}
80106
}
81107

82108
string pkgDir = Path.Combine(packagesDir, id);
@@ -91,7 +117,7 @@ private async Task BuildRuntimeAsync()
91117
continue;
92118
}
93119

94-
var deps = await _nuget.ResolveAllDependenciesAsync(id, version, selectedTfm);
120+
var deps = await _nuget.ResolveAllDependenciesAsync(id, version, selectedTfm, skipLicenseCheck: isExtra);
95121
if (deps is null)
96122
{
97123
await LogAsync($"{prefix} - skipped (dependency with non-permissive license)");

0 commit comments

Comments
 (0)