Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to fix runtime deps erroring #52

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Changes from all commits
Commits
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
27 changes: 24 additions & 3 deletions Plogon/BuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public class BuildProcessor
// If a plugin breaks with a missing runtime package you might want to add the package here.
private readonly Dictionary<string, string[]> RUNTIME_PACKAGES = new()
{
{ ".NETStandard,Version=v2.0", new[]
{ "2.0.0" }
},
{ "net5.0", new[]
{ "5.0.0" }
},
{ "net6.0", new[]
{ "6.0.0", "6.0.11" }
},
Expand Down Expand Up @@ -368,7 +374,20 @@ private async Task RestoreAllPackages(BuildTask task, DirectoryInfo localWorkFol
}

// fetch runtime packages
await Task.WhenAll(runtimeDependencies.Select(dependency => GetDependency(dependency.Item1, new() { Resolved = dependency.Item2 }, pkgFolder, client)));
try
{
await Task.WhenAll(
runtimeDependencies.Select(
dependency => GetDependency(
dependency.Item1,
new() { Resolved = dependency.Item2 },
pkgFolder,
client)));
}
catch (Exception e)
{
Log.Warning(e, "Failed to fetch runtime dependency");
}
}

async Task GetNeeds(BuildTask task, DirectoryInfo needs)
Expand Down Expand Up @@ -587,11 +606,13 @@ HashSet<Tuple<string, string>> GetRuntimeDependencies(NugetLockfile lockFileData

foreach (var runtime in lockFileData.Runtimes)
{
// e.g. net7.0, net7.0/linux-x64, net7.0-windows7.0
var key = runtime.Key.Split('/', '-')[0];
// check if framework identifier also specifies a runtime identifier
var runtimeId = runtime.Key.Split('/').Skip(1).FirstOrDefault();
var runtimeId = runtime.Key.Split('/').ElementAtOrDefault(1);

// add runtime packages to dependency list
if (!RUNTIME_PACKAGES.TryGetValue(runtime.Key[..6], out string[]? versions))
if (!RUNTIME_PACKAGES.TryGetValue(key, out string[]? versions))
{
throw new ArgumentOutOfRangeException($"Unknown runtime requested: {runtime}");
}
Expand Down
Loading