fix nuget
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m38s
Build / Build Nuget package (NuGet) (push) Successful in 2m24s
Build / Build Nuget package (CringePlugins) (push) Successful in 2m48s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m29s
Build / Build Launcher (push) Successful in 3m50s
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m38s
Build / Build Nuget package (NuGet) (push) Successful in 2m24s
Build / Build Nuget package (CringePlugins) (push) Successful in 2m48s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m29s
Build / Build Launcher (push) Successful in 3m50s
This commit is contained in:
@@ -29,6 +29,22 @@
|
|||||||
"NuGet.Versioning": "6.10.1"
|
"NuGet.Versioning": "6.10.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Basic.Reference.Assemblies.Net80": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "1wbS9ZJLFVrKD2jqv27gekIrpjpLffR9sitLQh5drWoG9KbyR/CgrAhw5I0c8Eq3zFMOToCmrpZi3VpRoInCgg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Basic.Reference.Assemblies.Net80Windows": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "98GFm8MC+pv37rTHaxBm5KFucqdJj0jK0XRHSGt2sXK9HNqtGImIFCFahxjUzskQjiUkPAzVhTou2OYZOuhhEg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dnlib": {
|
"dnlib": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "4.4.0",
|
"resolved": "4.4.0",
|
||||||
@@ -359,8 +375,8 @@
|
|||||||
},
|
},
|
||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "1.205.24",
|
"resolved": "1.205.25",
|
||||||
"contentHash": "cgzWJWflVITp+fY5OPgffcoJ08KL5YHMQrMwaDAkUxfRwPgTzU8qOADsrMqq25vXsEbznU1DzNWwTPviYYi7UA==",
|
"contentHash": "+70s6nJnBxEFYZY1qwKfM7FgYBYY6YDSPvbltEXrn7CVAeiWIxbtdcUZ4nDBGVTYqUWEI/r3zbLP1zlcNE27Dg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"SharpDX": "4.2.0-keen-cringe",
|
"SharpDX": "4.2.0-keen-cringe",
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
@@ -1294,7 +1310,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"CringeBootstrap.Abstractions": "[1.0.0, )",
|
"CringeBootstrap.Abstractions": "[1.0.0, )",
|
||||||
"CringePlugins": "[1.0.0, )",
|
"CringePlugins": "[1.0.0, )",
|
||||||
"ImGui.NET.DirectX": "[1.91.0.1, )",
|
|
||||||
"Lib.Harmony.Thin": "[2.3.3, )",
|
"Lib.Harmony.Thin": "[2.3.3, )",
|
||||||
"Microsoft.CodeAnalysis.CSharp": "[4.11.0, )",
|
"Microsoft.CodeAnalysis.CSharp": "[4.11.0, )",
|
||||||
"NLog": "[5.3.4, )",
|
"NLog": "[5.3.4, )",
|
||||||
@@ -1311,6 +1326,9 @@
|
|||||||
"cringeplugins": {
|
"cringeplugins": {
|
||||||
"type": "Project",
|
"type": "Project",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"Basic.Reference.Assemblies.Net80": "[1.7.9, )",
|
||||||
|
"Basic.Reference.Assemblies.Net80Windows": "[1.7.9, )",
|
||||||
|
"ImGui.NET.DirectX": "[1.91.0.1, )",
|
||||||
"NLog": "[5.3.4, )",
|
"NLog": "[5.3.4, )",
|
||||||
"NuGet": "[1.0.0, )",
|
"NuGet": "[1.0.0, )",
|
||||||
"SharedCringe": "[1.0.0, )",
|
"SharedCringe": "[1.0.0, )",
|
||||||
|
@@ -18,12 +18,11 @@
|
|||||||
<Publicize Include="Sandbox.Game:Sandbox.Engine.Platform.Game.set_DrawThread" />
|
<Publicize Include="Sandbox.Game:Sandbox.Engine.Platform.Game.set_DrawThread" />
|
||||||
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.form" />
|
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.form" />
|
||||||
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.RenderThread_SizeChanged" />
|
<Publicize Include="Sandbox.Game:Sandbox.MySandboxGame.RenderThread_SizeChanged" />
|
||||||
<Publicize Include="VRage.Render11;VRage.Platform.Windows" />
|
<Publicize Include="VRage.Render11;VRage.Platform.Windows;VRage.Scripting" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dnlib" Version="4.4.0" />
|
<PackageReference Include="dnlib" Version="4.4.0" />
|
||||||
<PackageReference Include="ImGui.NET.DirectX" Version="1.91.0.1" />
|
|
||||||
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@@ -8,17 +8,6 @@
|
|||||||
"resolved": "4.4.0",
|
"resolved": "4.4.0",
|
||||||
"contentHash": "cKHI720q+zfEEvzklWVGt6B0TH3AibAyJbpUJl4U6KvTP13tycfnqJpkGHRZ/oQ45BTIoIxIwltHIJVDN+iCqQ=="
|
"contentHash": "cKHI720q+zfEEvzklWVGt6B0TH3AibAyJbpUJl4U6KvTP13tycfnqJpkGHRZ/oQ45BTIoIxIwltHIJVDN+iCqQ=="
|
||||||
},
|
},
|
||||||
"ImGui.NET.DirectX": {
|
|
||||||
"type": "Direct",
|
|
||||||
"requested": "[1.91.0.1, )",
|
|
||||||
"resolved": "1.91.0.1",
|
|
||||||
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
|
||||||
"dependencies": {
|
|
||||||
"System.Buffers": "4.5.1",
|
|
||||||
"System.Numerics.Vectors": "4.5.0",
|
|
||||||
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Krafs.Publicizer": {
|
"Krafs.Publicizer": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[2.2.1, )",
|
"requested": "[2.2.1, )",
|
||||||
@@ -67,8 +56,8 @@
|
|||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.*, )",
|
"requested": "[1.*, )",
|
||||||
"resolved": "1.205.24",
|
"resolved": "1.205.25",
|
||||||
"contentHash": "cgzWJWflVITp+fY5OPgffcoJ08KL5YHMQrMwaDAkUxfRwPgTzU8qOADsrMqq25vXsEbznU1DzNWwTPviYYi7UA==",
|
"contentHash": "+70s6nJnBxEFYZY1qwKfM7FgYBYY6YDSPvbltEXrn7CVAeiWIxbtdcUZ4nDBGVTYqUWEI/r3zbLP1zlcNE27Dg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"SharpDX": "4.2.0-keen-cringe",
|
"SharpDX": "4.2.0-keen-cringe",
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
@@ -132,6 +121,32 @@
|
|||||||
"NuGet.Versioning": "6.10.1"
|
"NuGet.Versioning": "6.10.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Basic.Reference.Assemblies.Net80": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "1wbS9ZJLFVrKD2jqv27gekIrpjpLffR9sitLQh5drWoG9KbyR/CgrAhw5I0c8Eq3zFMOToCmrpZi3VpRoInCgg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Basic.Reference.Assemblies.Net80Windows": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "98GFm8MC+pv37rTHaxBm5KFucqdJj0jK0XRHSGt2sXK9HNqtGImIFCFahxjUzskQjiUkPAzVhTou2OYZOuhhEg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Microsoft.Bcl.AsyncInterfaces": {
|
"Microsoft.Bcl.AsyncInterfaces": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "5.0.0",
|
"resolved": "5.0.0",
|
||||||
@@ -363,6 +378,9 @@
|
|||||||
"cringeplugins": {
|
"cringeplugins": {
|
||||||
"type": "Project",
|
"type": "Project",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"Basic.Reference.Assemblies.Net80": "[1.7.9, )",
|
||||||
|
"Basic.Reference.Assemblies.Net80Windows": "[1.7.9, )",
|
||||||
|
"ImGui.NET.DirectX": "[1.91.0.1, )",
|
||||||
"NLog": "[5.3.4, )",
|
"NLog": "[5.3.4, )",
|
||||||
"NuGet": "[1.0.0, )",
|
"NuGet": "[1.0.0, )",
|
||||||
"SharedCringe": "[1.0.0, )",
|
"SharedCringe": "[1.0.0, )",
|
||||||
@@ -387,17 +405,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"net8.0-windows10.0.19041/win-x64": {
|
"net8.0-windows10.0.19041/win-x64": {
|
||||||
"ImGui.NET.DirectX": {
|
|
||||||
"type": "Direct",
|
|
||||||
"requested": "[1.91.0.1, )",
|
|
||||||
"resolved": "1.91.0.1",
|
|
||||||
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
|
||||||
"dependencies": {
|
|
||||||
"System.Buffers": "4.5.1",
|
|
||||||
"System.Numerics.Vectors": "4.5.0",
|
|
||||||
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Steamworks.NET": {
|
"Steamworks.NET": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[20.1.0, )",
|
"requested": "[20.1.0, )",
|
||||||
@@ -422,6 +429,16 @@
|
|||||||
"System.CodeDom": "8.0.0"
|
"System.CodeDom": "8.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"System.Diagnostics.EventLog": {
|
"System.Diagnostics.EventLog": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "8.0.0",
|
"resolved": "8.0.0",
|
||||||
|
@@ -8,6 +8,8 @@ namespace CringePlugins.Config;
|
|||||||
public record PackagesConfig(ImmutableArray<PackageSource> Sources, ImmutableArray<PackageReference> Packages)
|
public record PackagesConfig(ImmutableArray<PackageSource> Sources, ImmutableArray<PackageReference> Packages)
|
||||||
{
|
{
|
||||||
public static PackagesConfig Default { get; } = new([
|
public static PackagesConfig Default { get; } = new([
|
||||||
|
new("SpaceEngineersDedicated.ReferenceAssemblies", "https://nuget.storage.yandexcloud.net/index.json"),
|
||||||
|
new("ImGui.NET.DirectX", "https://nuget.storage.yandexcloud.net/index.json"),
|
||||||
new(string.Empty, "https://api.nuget.org/v3/index.json")
|
new(string.Empty, "https://api.nuget.org/v3/index.json")
|
||||||
], []);
|
], []);
|
||||||
}
|
}
|
@@ -21,7 +21,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.9" />
|
||||||
|
<PackageReference Include="Basic.Reference.Assemblies.Net80Windows" Version="1.7.9" />
|
||||||
<PackageReference Include="NLog" Version="5.3.4" />
|
<PackageReference Include="NLog" Version="5.3.4" />
|
||||||
|
<PackageReference Include="ImGui.NET.DirectX" Version="1.91.0.1" />
|
||||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.*" ExcludeAssets="runtime" />
|
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.*" ExcludeAssets="runtime" />
|
||||||
<PackageReference Include="dnlib" Version="4.4.0" />
|
<PackageReference Include="dnlib" Version="4.4.0" />
|
||||||
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
<PackageReference Include="Krafs.Publicizer" Version="2.2.1">
|
||||||
|
@@ -8,6 +8,7 @@ using NLog;
|
|||||||
using NuGet;
|
using NuGet;
|
||||||
using NuGet.Deps;
|
using NuGet.Deps;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
namespace CringePlugins.Loader;
|
namespace CringePlugins.Loader;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public class PluginsLifetime : ILoadingStage
|
|||||||
|
|
||||||
private ImmutableArray<PluginInstance> _plugins = [];
|
private ImmutableArray<PluginInstance> _plugins = [];
|
||||||
private readonly DirectoryInfo _dir = Directory.CreateDirectory(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher"));
|
private readonly DirectoryInfo _dir = Directory.CreateDirectory(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CringeLauncher"));
|
||||||
private readonly NuGetFramework _runtimeFramework = NuGetFramework.ParseFolder("net8.0-windows");
|
private readonly NuGetFramework _runtimeFramework = NuGetFramework.ParseFolder("net8.0-windows10.0.19041.0");
|
||||||
|
|
||||||
public async ValueTask Load(ISplashProgress progress)
|
public async ValueTask Load(ISplashProgress progress)
|
||||||
{
|
{
|
||||||
@@ -84,17 +85,24 @@ public class PluginsLifetime : ILoadingStage
|
|||||||
{
|
{
|
||||||
var plugins = _plugins.ToBuilder();
|
var plugins = _plugins.ToBuilder();
|
||||||
|
|
||||||
|
var packageVersions = BuiltInPackages.GetPackages(_runtimeFramework)
|
||||||
|
.ToImmutableDictionary(b => b.Package.Id, b => b.Package.Version,
|
||||||
|
StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
packageVersions = packageVersions.AddRange(packages.Select(b =>
|
||||||
|
new KeyValuePair<string, NuGetVersion>(b.Package.Id, b.Package.Version)));
|
||||||
|
|
||||||
|
var manifestBuilder = new DependencyManifestBuilder(_dir.CreateSubdirectory("cache"), sourceMapping,
|
||||||
|
dependency => packageVersions.TryGetValue(dependency.Id, out var version) && version.Major != 99
|
||||||
|
? version
|
||||||
|
: dependency.Range.MinVersion ?? dependency.Range.MaxVersion);
|
||||||
|
|
||||||
foreach (var package in packages)
|
foreach (var package in packages)
|
||||||
{
|
{
|
||||||
var dir = Path.Join(package.Directory.FullName, "lib", package.ResolvedFramework.GetShortFolderName());
|
var dir = Path.Join(package.Directory.FullName, "lib", package.ResolvedFramework.GetShortFolderName());
|
||||||
|
|
||||||
await using (var stream = File.Create(Path.Join(dir, $"{package.Package.Id}.deps.json")))
|
await using (var stream = File.Create(Path.Join(dir, $"{package.Package.Id}.deps.json")))
|
||||||
await DependencyManifestUtility.WriteDependencyManifestAsync(stream, package.Entry, _runtimeFramework,
|
await manifestBuilder.WriteDependencyManifestAsync(stream, package.Entry, _runtimeFramework);
|
||||||
sourceMapping,
|
|
||||||
dependency =>
|
|
||||||
packages.First(b => b.Package.Id.Equals(dependency.Id, StringComparison.OrdinalIgnoreCase))
|
|
||||||
.Package
|
|
||||||
.Version);
|
|
||||||
|
|
||||||
LoadComponent(plugins, Path.Join(dir, $"{package.Package.Id}.dll"));
|
LoadComponent(plugins, Path.Join(dir, $"{package.Package.Id}.dll"));
|
||||||
}
|
}
|
||||||
|
78
CringePlugins/Resolver/BuiltInPackages.cs
Normal file
78
CringePlugins/Resolver/BuiltInPackages.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using System.Collections.Immutable;
|
||||||
|
using System.Reflection;
|
||||||
|
using Basic.Reference.Assemblies;
|
||||||
|
using CringePlugins.Loader;
|
||||||
|
using CringePlugins.Utils;
|
||||||
|
using dnlib.DotNet;
|
||||||
|
using ImGuiNET;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using NLog;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
using NuGet.Models;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
using Sandbox.Game;
|
||||||
|
using SpaceEngineers.Game;
|
||||||
|
using VRage.Utils;
|
||||||
|
|
||||||
|
namespace CringePlugins.Resolver;
|
||||||
|
|
||||||
|
public static class BuiltInPackages
|
||||||
|
{
|
||||||
|
private const string SeReferenceAssemblies = "SpaceEngineersDedicated.ReferenceAssemblies";
|
||||||
|
private const string ImGui = "ImGui.NET.DirectX";
|
||||||
|
|
||||||
|
public static ImmutableArray<ResolvedPackage> GetPackages(NuGetFramework runtimeFramework)
|
||||||
|
{
|
||||||
|
var nlog = FromAssembly<LogFactory>(runtimeFramework, version: new(5, 3, 4));
|
||||||
|
Version seVersion = new MyVersion(MyPerGameSettings.BasicGameInfo.GameVersion!.Value);
|
||||||
|
|
||||||
|
var se = FromAssembly<SpaceEngineersGame>(runtimeFramework, [
|
||||||
|
nlog.AsDependency()
|
||||||
|
], SeReferenceAssemblies, new(seVersion));
|
||||||
|
var imGui = FromAssembly<ImGuiKey>(runtimeFramework, id: ImGui);
|
||||||
|
|
||||||
|
BuiltInSdkPackage MapSdkPackage(
|
||||||
|
(string FileName, byte[] ImageBytes, PortableExecutableReference Reference, Guid Mvid) r)
|
||||||
|
{
|
||||||
|
var def = ModuleDefMD.Load(r.ImageBytes, IntrospectionContext.Global.Context);
|
||||||
|
var attribute = def.CustomAttributes.Find(typeof(AssemblyFileVersionAttribute).FullName);
|
||||||
|
var version = attribute is null ? new(99, 0, 0) : NuGetVersion.Parse((string)attribute.ConstructorArguments[0].Value);
|
||||||
|
|
||||||
|
return new BuiltInSdkPackage(
|
||||||
|
new(0, Path.GetFileNameWithoutExtension(r.FileName), version, []), runtimeFramework,
|
||||||
|
new(Path.GetFileNameWithoutExtension(r.FileName), version, [new(runtimeFramework, [])], null, []));
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
[
|
||||||
|
..Net80.ReferenceInfos.AllValues.Select(MapSdkPackage),
|
||||||
|
..Net80Windows.ReferenceInfos.AllValues.Select(MapSdkPackage),
|
||||||
|
nlog,
|
||||||
|
se,
|
||||||
|
imGui,
|
||||||
|
FromAssembly<PluginsLifetime>(runtimeFramework, [se.AsDependency(), imGui.AsDependency()]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dependency AsDependency(this ResolvedPackage package) => new(package.Package.Id, new(package.Package.Version));
|
||||||
|
|
||||||
|
private static BuiltInPackage FromAssembly<T>(NuGetFramework runtimeFramework, ImmutableArray<Dependency>? dependencies = null, string? id = null, NuGetVersion? version = null)
|
||||||
|
{
|
||||||
|
var assembly = typeof(T).Assembly.GetName();
|
||||||
|
id ??= assembly.Name!;
|
||||||
|
version ??= new NuGetVersion(assembly.Version ?? new(0, 0, 0));
|
||||||
|
dependencies ??= [];
|
||||||
|
|
||||||
|
return new(
|
||||||
|
new(0, id, version, [..dependencies.Value.Select(b => b.Id)]),
|
||||||
|
runtimeFramework,
|
||||||
|
new(id, version, [
|
||||||
|
new(runtimeFramework, dependencies.Value)
|
||||||
|
], null, [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record BuiltInPackage(Package Package, NuGetFramework ResolvedFramework, CatalogEntry Entry) : ResolvedPackage(Package, ResolvedFramework, Entry);
|
||||||
|
|
||||||
|
public record BuiltInSdkPackage(Package Package, NuGetFramework ResolvedFramework, CatalogEntry Entry) : BuiltInPackage(Package, ResolvedFramework, Entry);
|
@@ -12,7 +12,7 @@ public class PackageResolver(NuGetFramework runtimeFramework, ImmutableArray<Pac
|
|||||||
public async Task<ImmutableHashSet<ResolvedPackage>> ResolveAsync()
|
public async Task<ImmutableHashSet<ResolvedPackage>> ResolveAsync()
|
||||||
{
|
{
|
||||||
var order = 0;
|
var order = 0;
|
||||||
var packages = new SortedSet<Package>();
|
var packages = new SortedDictionary<Package, CatalogEntry>();
|
||||||
|
|
||||||
foreach (var reference in references)
|
foreach (var reference in references)
|
||||||
{
|
{
|
||||||
@@ -20,25 +20,25 @@ public class PackageResolver(NuGetFramework runtimeFramework, ImmutableArray<Pac
|
|||||||
|
|
||||||
var registrationRoot = await client.GetPackageRegistrationRootAsync(reference.Id);
|
var registrationRoot = await client.GetPackageRegistrationRootAsync(reference.Id);
|
||||||
|
|
||||||
NuGetVersion? version = null;
|
var items = registrationRoot.Items.SelectMany(page =>
|
||||||
foreach (var page in registrationRoot.Items)
|
page.Items.Where(b => b.CatalogEntry.PackageTypes is ["CringePlugin"]))
|
||||||
{
|
.ToImmutableDictionary(b => b.CatalogEntry.Version);
|
||||||
version = reference.Range.FindBestMatch(page.Items.Where(b => b.CatalogEntry.PackageTypes is [{ Name: "CringePlugin" }]).Select(b => b.CatalogEntry.Version));
|
|
||||||
if (version is not null)
|
var version = reference.Range.FindBestMatch(items.Values.Select(b => b.CatalogEntry.Version));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version is null)
|
if (version is null)
|
||||||
throw new Exception($"Unable to find version for package {reference.Id}");
|
throw new Exception($"Unable to find version for package {reference.Id}");
|
||||||
|
|
||||||
var package = new Package(order, reference.Id, version, []); // todo resolve dependencies
|
var package = new Package(order, reference.Id, version, []); // todo resolve dependencies
|
||||||
|
|
||||||
if (packages.Add(package))
|
if (packages.TryAdd(package, items[version].CatalogEntry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!packages.TryGetValue(package, out var existingPackage))
|
if (!packages.TryGetValue(package, out _))
|
||||||
throw new Exception($"Duplicate package {package.Id}");
|
throw new Exception($"Duplicate package {package.Id}");
|
||||||
|
|
||||||
|
var existingPackage = packages.Keys.First(b => b.Version == package.Version && b.Id == package.Id);
|
||||||
|
|
||||||
if (package.Version < existingPackage.Version)
|
if (package.Version < existingPackage.Version)
|
||||||
throw new Exception($"Package reference {package.Id} has lower version {package.Version} than already resolved {existingPackage.Version}");
|
throw new Exception($"Package reference {package.Id} has lower version {package.Version} than already resolved {existingPackage.Version}");
|
||||||
|
|
||||||
@@ -49,18 +49,14 @@ public class PackageResolver(NuGetFramework runtimeFramework, ImmutableArray<Pac
|
|||||||
packages.Add(package with
|
packages.Add(package with
|
||||||
{
|
{
|
||||||
Order = ++order
|
Order = ++order
|
||||||
});
|
}, items[version].CatalogEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
var set = ImmutableHashSet<ResolvedPackage>.Empty.ToBuilder();
|
var set = ImmutableHashSet<ResolvedPackage>.Empty.ToBuilder();
|
||||||
foreach (var package in packages)
|
foreach (var (package, catalogEntry) in packages)
|
||||||
{
|
{
|
||||||
var client = await packageSources.GetClientAsync(package.Id);
|
var client = await packageSources.GetClientAsync(package.Id);
|
||||||
|
|
||||||
var (catalogEntryUrl, catalogEntry) = await client.GetPackageRegistrationAsync(package.Id, package.Version);
|
|
||||||
|
|
||||||
catalogEntry ??= await client.GetPackageCatalogEntryAsync(catalogEntryUrl);
|
|
||||||
|
|
||||||
var nearestGroup = NuGetFrameworkUtility.GetNearest(catalogEntry.DependencyGroups, runtimeFramework,
|
var nearestGroup = NuGetFrameworkUtility.GetNearest(catalogEntry.DependencyGroups, runtimeFramework,
|
||||||
g => g.TargetFramework);
|
g => g.TargetFramework);
|
||||||
|
|
||||||
|
@@ -7,11 +7,11 @@ public class IntrospectionContext
|
|||||||
{
|
{
|
||||||
public static IntrospectionContext Global { get; } = new();
|
public static IntrospectionContext Global { get; } = new();
|
||||||
|
|
||||||
private readonly ModuleContext _context = ModuleDef.CreateModuleContext();
|
internal readonly ModuleContext Context = ModuleDef.CreateModuleContext();
|
||||||
|
|
||||||
public IEnumerable<Type> CollectAttributedTypes<TAttribute>(Module module, bool allowAbstract = false) where TAttribute : Attribute
|
public IEnumerable<Type> CollectAttributedTypes<TAttribute>(Module module, bool allowAbstract = false) where TAttribute : Attribute
|
||||||
{
|
{
|
||||||
var moduleDef = ModuleDefMD.Load(module, _context);
|
var moduleDef = ModuleDefMD.Load(module, Context);
|
||||||
|
|
||||||
return moduleDef.GetTypes()
|
return moduleDef.GetTypes()
|
||||||
.Where(b => b.CustomAttributes.IsDefined(typeof(TAttribute).FullName) && (allowAbstract || !b.IsAbstract))
|
.Where(b => b.CustomAttributes.IsDefined(typeof(TAttribute).FullName) && (allowAbstract || !b.IsAbstract))
|
||||||
@@ -20,7 +20,7 @@ public class IntrospectionContext
|
|||||||
|
|
||||||
public IEnumerable<Type> CollectDerivedTypes<T>(Module module, bool allowAbstract = false)
|
public IEnumerable<Type> CollectDerivedTypes<T>(Module module, bool allowAbstract = false)
|
||||||
{
|
{
|
||||||
var moduleDef = ModuleDefMD.Load(module, _context);
|
var moduleDef = ModuleDefMD.Load(module, Context);
|
||||||
|
|
||||||
var token = moduleDef.ImportAsTypeSig(typeof(T));
|
var token = moduleDef.ImportAsTypeSig(typeof(T));
|
||||||
|
|
||||||
|
@@ -2,12 +2,41 @@
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"net8.0-windows7.0": {
|
"net8.0-windows7.0": {
|
||||||
|
"Basic.Reference.Assemblies.Net80": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.7.9, )",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "1wbS9ZJLFVrKD2jqv27gekIrpjpLffR9sitLQh5drWoG9KbyR/CgrAhw5I0c8Eq3zFMOToCmrpZi3VpRoInCgg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Basic.Reference.Assemblies.Net80Windows": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.7.9, )",
|
||||||
|
"resolved": "1.7.9",
|
||||||
|
"contentHash": "98GFm8MC+pv37rTHaxBm5KFucqdJj0jK0XRHSGt2sXK9HNqtGImIFCFahxjUzskQjiUkPAzVhTou2OYZOuhhEg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Common": "4.11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"dnlib": {
|
"dnlib": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[4.4.0, )",
|
"requested": "[4.4.0, )",
|
||||||
"resolved": "4.4.0",
|
"resolved": "4.4.0",
|
||||||
"contentHash": "cKHI720q+zfEEvzklWVGt6B0TH3AibAyJbpUJl4U6KvTP13tycfnqJpkGHRZ/oQ45BTIoIxIwltHIJVDN+iCqQ=="
|
"contentHash": "cKHI720q+zfEEvzklWVGt6B0TH3AibAyJbpUJl4U6KvTP13tycfnqJpkGHRZ/oQ45BTIoIxIwltHIJVDN+iCqQ=="
|
||||||
},
|
},
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.91.0.1, )",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Krafs.Publicizer": {
|
"Krafs.Publicizer": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[2.2.1, )",
|
"requested": "[2.2.1, )",
|
||||||
@@ -23,13 +52,28 @@
|
|||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.*, )",
|
"requested": "[1.*, )",
|
||||||
"resolved": "1.205.24",
|
"resolved": "1.205.25",
|
||||||
"contentHash": "cgzWJWflVITp+fY5OPgffcoJ08KL5YHMQrMwaDAkUxfRwPgTzU8qOADsrMqq25vXsEbznU1DzNWwTPviYYi7UA==",
|
"contentHash": "+70s6nJnBxEFYZY1qwKfM7FgYBYY6YDSPvbltEXrn7CVAeiWIxbtdcUZ4nDBGVTYqUWEI/r3zbLP1zlcNE27Dg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"SharpDX": "4.2.0-keen-cringe",
|
"SharpDX": "4.2.0-keen-cringe",
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Microsoft.CodeAnalysis.Analyzers": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "3.3.4",
|
||||||
|
"contentHash": "AxkxcPR+rheX0SmvpLVIGLhOUXAKG56a64kV9VQZ4y9gR9ZmPXnqZvHJnmwLSwzrEP6junUF11vuc+aqo5r68g=="
|
||||||
|
},
|
||||||
|
"Microsoft.CodeAnalysis.Common": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.11.0",
|
||||||
|
"contentHash": "djf8ujmqYImFgB04UGtcsEhHrzVqzHowS+EEl/Yunc5LdrYrZhGBWUTXoCF0NzYXJxtfuD+UVQarWpvrNc94Qg==",
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.Analyzers": "3.3.4",
|
||||||
|
"System.Collections.Immutable": "8.0.0",
|
||||||
|
"System.Reflection.Metadata": "8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"NuGet.Frameworks": {
|
"NuGet.Frameworks": {
|
||||||
"type": "Transitive",
|
"type": "Transitive",
|
||||||
"resolved": "6.11.1",
|
"resolved": "6.11.1",
|
||||||
@@ -50,6 +94,34 @@
|
|||||||
"resolved": "4.2.0-keen-cringe",
|
"resolved": "4.2.0-keen-cringe",
|
||||||
"contentHash": "LaJN3h1Gi1FWVdef2I5WtOH9gwzKCBniH0CragarbkN2QheYY6Lqm+91PcOfp1w/4wdVb+k8Kjv3sO393Tphtw=="
|
"contentHash": "LaJN3h1Gi1FWVdef2I5WtOH9gwzKCBniH0CragarbkN2QheYY6Lqm+91PcOfp1w/4wdVb+k8Kjv3sO393Tphtw=="
|
||||||
},
|
},
|
||||||
|
"System.Buffers": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.5.1",
|
||||||
|
"contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
|
||||||
|
},
|
||||||
|
"System.Collections.Immutable": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "8.0.0",
|
||||||
|
"contentHash": "AurL6Y5BA1WotzlEvVaIDpqzpIPvYnnldxru8oXJU2yFxFUy3+pNXjXd1ymO+RA0rq0+590Q8gaz2l3Sr7fmqg=="
|
||||||
|
},
|
||||||
|
"System.Numerics.Vectors": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.5.0",
|
||||||
|
"contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ=="
|
||||||
|
},
|
||||||
|
"System.Reflection.Metadata": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "8.0.0",
|
||||||
|
"contentHash": "ptvgrFh7PvWI8bcVqG5rsA/weWM09EnthFHR5SCnS6IN+P4mj6rE1lBDC4U8HL9/57htKAqy4KQ3bBj84cfYyQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Collections.Immutable": "8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "6.0.0",
|
||||||
|
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
|
||||||
|
},
|
||||||
"cringebootstrap.abstractions": {
|
"cringebootstrap.abstractions": {
|
||||||
"type": "Project"
|
"type": "Project"
|
||||||
},
|
},
|
||||||
@@ -69,6 +141,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"net8.0-windows7.0/win-x64": {}
|
"net8.0-windows7.0/win-x64": {
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.91.0.1, )",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -6,7 +6,7 @@ namespace NuGet.Converters;
|
|||||||
|
|
||||||
public class FrameworkJsonConverter(FrameworkNameFormat format) : JsonConverter<NuGetFramework>
|
public class FrameworkJsonConverter(FrameworkNameFormat format) : JsonConverter<NuGetFramework>
|
||||||
{
|
{
|
||||||
public override NuGetFramework? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override NuGetFramework Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
if (reader.TokenType != JsonTokenType.String)
|
if (reader.TokenType != JsonTokenType.String)
|
||||||
throw new JsonException("Invalid framework string");
|
throw new JsonException("Invalid framework string");
|
||||||
@@ -23,12 +23,26 @@ public class FrameworkJsonConverter(FrameworkNameFormat format) : JsonConverter<
|
|||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, NuGetFramework value, JsonSerializerOptions options)
|
public override void Write(Utf8JsonWriter writer, NuGetFramework value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
writer.WriteStringValue(format switch
|
writer.WriteStringValue(FormatValue(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string FormatValue(NuGetFramework value)
|
||||||
|
{
|
||||||
|
return format switch
|
||||||
{
|
{
|
||||||
FrameworkNameFormat.ShortFolderName => value.GetShortFolderName(),
|
FrameworkNameFormat.ShortFolderName => value.GetShortFolderName(),
|
||||||
FrameworkNameFormat.FrameworkName => value.DotNetFrameworkName,
|
FrameworkNameFormat.FrameworkName => value.DotNetFrameworkName,
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override NuGetFramework ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert,
|
||||||
|
JsonSerializerOptions options) => Read(ref reader, typeToConvert, options);
|
||||||
|
|
||||||
|
public override void WriteAsPropertyName(Utf8JsonWriter writer, NuGetFramework value,
|
||||||
|
JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
writer.WritePropertyName(FormatValue(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,5 +23,8 @@ public class ManifestPackageKeyJsonConverter : JsonConverter<ManifestPackageKey>
|
|||||||
JsonSerializerOptions options) => Read(ref reader, typeToConvert, options);
|
JsonSerializerOptions options) => Read(ref reader, typeToConvert, options);
|
||||||
|
|
||||||
public override void WriteAsPropertyName(Utf8JsonWriter writer, ManifestPackageKey value,
|
public override void WriteAsPropertyName(Utf8JsonWriter writer, ManifestPackageKey value,
|
||||||
JsonSerializerOptions options) => Write(writer, value, options);
|
JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
writer.WritePropertyName(value.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
@@ -55,7 +56,7 @@ public record ManifestPackageKey(string Id, NuGetVersion Version)
|
|||||||
public override string ToString() => $"{Id}/{Version}";
|
public override string ToString() => $"{Id}/{Version}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DependencyManifestUtility
|
public class DependencyManifestBuilder(DirectoryInfo cacheDirectory, PackageSourceMapping packageSources, Func<Models.Dependency, NuGetVersion?> versionResolver)
|
||||||
{
|
{
|
||||||
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web)
|
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web)
|
||||||
{
|
{
|
||||||
@@ -68,14 +69,13 @@ public static class DependencyManifestUtility
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static async ValueTask WriteDependencyManifestAsync(Stream stream, CatalogEntry catalogEntry, NuGetFramework targetFramework,
|
public async ValueTask WriteDependencyManifestAsync(Stream stream, CatalogEntry catalogEntry, NuGetFramework targetFramework)
|
||||||
PackageSourceMapping packageSources, Func<Models.Dependency, NuGetVersion> versionResolver)
|
|
||||||
{
|
{
|
||||||
var runtimeTarget = new RuntimeTarget(targetFramework);
|
var runtimeTarget = new RuntimeTarget(targetFramework);
|
||||||
|
|
||||||
var targets = ImmutableDictionary<ManifestPackageKey, DependencyTarget>.Empty.ToBuilder();
|
var targets = ImmutableDictionary<ManifestPackageKey, DependencyTarget>.Empty.ToBuilder();
|
||||||
|
|
||||||
await MapCatalogEntry(catalogEntry, targetFramework, packageSources, versionResolver, targets);
|
await MapCatalogEntryAsync(catalogEntry, targetFramework, targets);
|
||||||
|
|
||||||
var manifest = new DependenciesManifest(runtimeTarget, ImmutableDictionary<NuGetFramework, string>.Empty,
|
var manifest = new DependenciesManifest(runtimeTarget, ImmutableDictionary<NuGetFramework, string>.Empty,
|
||||||
ImmutableDictionary<NuGetFramework, ImmutableDictionary<ManifestPackageKey, DependencyTarget>>.Empty
|
ImmutableDictionary<NuGetFramework, ImmutableDictionary<ManifestPackageKey, DependencyTarget>>.Empty
|
||||||
@@ -85,8 +85,8 @@ public static class DependencyManifestUtility
|
|||||||
await JsonSerializer.SerializeAsync(stream, manifest, SerializerOptions);
|
await JsonSerializer.SerializeAsync(stream, manifest, SerializerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task MapCatalogEntry(CatalogEntry catalogEntry, NuGetFramework targetFramework,
|
private async Task MapCatalogEntryAsync(CatalogEntry catalogEntry, NuGetFramework targetFramework,
|
||||||
PackageSourceMapping packageSources, Func<Models.Dependency, NuGetVersion> versionResolver, ImmutableDictionary<ManifestPackageKey, DependencyTarget>.Builder targets)
|
ImmutableDictionary<ManifestPackageKey, DependencyTarget>.Builder targets)
|
||||||
{
|
{
|
||||||
if (targets.ContainsKey(new(catalogEntry.Id, catalogEntry.Version)))
|
if (targets.ContainsKey(new(catalogEntry.Id, catalogEntry.Version)))
|
||||||
return;
|
return;
|
||||||
@@ -98,26 +98,58 @@ public static class DependencyManifestUtility
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
targets.Add(new(catalogEntry.Id, catalogEntry.Version),
|
targets.Add(new(catalogEntry.Id, catalogEntry.Version),
|
||||||
MapEntry(catalogEntry, nearest, targetFramework, versionResolver));
|
await MapEntryAsync(catalogEntry, nearest));
|
||||||
|
|
||||||
foreach (var dependency in nearest.Dependencies)
|
foreach (var dependency in nearest.Dependencies ?? [])
|
||||||
{
|
{
|
||||||
var client = await packageSources.GetClientAsync(dependency.Id);
|
var client = await packageSources.GetClientAsync(dependency.Id);
|
||||||
var (url, entry) = await client.GetPackageRegistrationAsync(dependency.Id, versionResolver(dependency));
|
var (url, entry) = await client.GetPackageRegistrationAsync(dependency.Id, versionResolver(dependency)!);
|
||||||
|
|
||||||
entry ??= await client.GetPackageCatalogEntryAsync(url);
|
entry ??= await client.GetPackageCatalogEntryAsync(url);
|
||||||
|
|
||||||
await MapCatalogEntry(entry, targetFramework, packageSources, versionResolver, targets);
|
await MapCatalogEntryAsync(entry, targetFramework, targets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DependencyTarget MapEntry(CatalogEntry entry, DependencyGroup group, NuGetFramework targetFramework, Func<Models.Dependency, NuGetVersion> versionResolver)
|
private async Task<DependencyTarget> MapEntryAsync(CatalogEntry entry, DependencyGroup group)
|
||||||
{
|
{
|
||||||
return new(group.Dependencies.ToImmutableDictionary(b => b.Id, versionResolver),
|
var packageEntries = entry.PackageEntries ?? await GetPackageContent(entry);
|
||||||
entry.PackageEntries.Where(b => b.FullName.StartsWith($"lib/{targetFramework.GetShortFolderName()}/"))
|
|
||||||
|
return new(group.Dependencies?.ToImmutableDictionary(b => b.Id, versionResolver) ?? ImmutableDictionary<string, NuGetVersion>.Empty,
|
||||||
|
packageEntries.Where(b => b.FullName.StartsWith($"lib/{group.TargetFramework.GetShortFolderName()}/"))
|
||||||
.ToImmutableDictionary(b => b.FullName, _ => new RuntimeDependency()),
|
.ToImmutableDictionary(b => b.FullName, _ => new RuntimeDependency()),
|
||||||
entry.PackageEntries.Where(b =>
|
packageEntries.Where(b =>
|
||||||
b.FullName.StartsWith($"runtimes/{RuntimeInformation.RuntimeIdentifier}/native/"))
|
b.FullName.StartsWith($"runtimes/{RuntimeInformation.RuntimeIdentifier}/native/"))
|
||||||
.ToImmutableDictionary(b => b.FullName, _ => new Dependency()));
|
.ToImmutableDictionary(b => b.FullName, _ => new Dependency()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<ImmutableArray<CatalogPackageEntry>> GetPackageContent(CatalogEntry entry)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var dir = new DirectoryInfo(Path.Join(cacheDirectory.FullName, entry.Id, entry.Version.ToString()));
|
||||||
|
|
||||||
|
if (dir.Exists)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
[
|
||||||
|
..dir.EnumerateFiles("*", SearchOption.AllDirectories)
|
||||||
|
.Select(b => new CatalogPackageEntry(b.Name, b.FullName, b.Length, b.Length))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
var client = await packageSources.GetClientAsync(entry.Id);
|
||||||
|
|
||||||
|
dir.Create();
|
||||||
|
|
||||||
|
{
|
||||||
|
await using var stream = await client.GetPackageContentStreamAsync(entry.Id, entry.Version);
|
||||||
|
using var memStream = new MemoryStream();
|
||||||
|
await stream.CopyToAsync(memStream);
|
||||||
|
memStream.Position = 0;
|
||||||
|
using var archive = new ZipArchive(memStream, ZipArchiveMode.Read);
|
||||||
|
archive.ExtractToDirectory(dir.FullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,9 +1,9 @@
|
|||||||
using NuGet.Versioning;
|
using System.Collections.Immutable;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
namespace NuGet.Models;
|
namespace NuGet.Models;
|
||||||
|
|
||||||
public record CatalogEntry(string Id, NuGetVersion Version, DependencyGroup[] DependencyGroups, PackageType[]? PackageTypes,
|
public record CatalogEntry(string Id, NuGetVersion Version, ImmutableArray<DependencyGroup> DependencyGroups, ImmutableArray<string>? PackageTypes,
|
||||||
CatalogPackageEntry[] PackageEntries,
|
ImmutableArray<CatalogPackageEntry>? PackageEntries);
|
||||||
bool Serviceable = true);
|
|
||||||
|
|
||||||
public record CatalogPackageEntry(string Name, string FullName, long CompressedLength, long Length);
|
public record CatalogPackageEntry(string Name, string FullName, long CompressedLength, long Length);
|
@@ -1,5 +1,6 @@
|
|||||||
using NuGet.Frameworks;
|
using System.Collections.Immutable;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace NuGet.Models;
|
namespace NuGet.Models;
|
||||||
|
|
||||||
public record DependencyGroup(NuGetFramework TargetFramework, Dependency[] Dependencies);
|
public record DependencyGroup(NuGetFramework TargetFramework, ImmutableArray<Dependency>? Dependencies = null);
|
@@ -1,3 +0,0 @@
|
|||||||
namespace NuGet.Models;
|
|
||||||
|
|
||||||
public record PackageType(string Name);
|
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using NuGet.Converters;
|
using NuGet.Converters;
|
||||||
using NuGet.Models;
|
using NuGet.Models;
|
||||||
@@ -32,8 +33,9 @@ public class NuGetClient
|
|||||||
|
|
||||||
public Task<Stream> GetPackageContentStreamAsync(string id, NuGetVersion version)
|
public Task<Stream> GetPackageContentStreamAsync(string id, NuGetVersion version)
|
||||||
{
|
{
|
||||||
|
id = id.ToLower();
|
||||||
return _client.GetStreamAsync(new Uri(_packageBaseAddress,
|
return _client.GetStreamAsync(new Uri(_packageBaseAddress,
|
||||||
new Uri($"{id.ToLower()}/{version}.nupkg", UriKind.Relative)));
|
new Uri($"{id}/{version}/{id}.{version}.nupkg", UriKind.Relative)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Registration> GetPackageRegistrationAsync(string id, NuGetVersion version)
|
public Task<Registration> GetPackageRegistrationAsync(string id, NuGetVersion version)
|
||||||
@@ -61,13 +63,21 @@ public class NuGetClient
|
|||||||
|
|
||||||
public static async Task<NuGetClient> CreateFromIndexUrlAsync(string indexUrl)
|
public static async Task<NuGetClient> CreateFromIndexUrlAsync(string indexUrl)
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
var client = new HttpClient(new HttpClientHandler
|
||||||
|
{
|
||||||
|
AutomaticDecompression = DecompressionMethods.All
|
||||||
|
});
|
||||||
|
|
||||||
var index = await client.GetFromJsonAsync<NuGetIndex>(indexUrl, SerializerOptions);
|
var index = await client.GetFromJsonAsync<NuGetIndex>(indexUrl, SerializerOptions);
|
||||||
|
|
||||||
var (packageBaseAddress, _, _) = index!.Resources.First(b => b.Type.Id == "PackageBaseAddress");
|
var (packageBaseAddress, _, _) = index!.Resources.First(b => b.Type.Id == "PackageBaseAddress");
|
||||||
var (registration, _, _) = index!.Resources.First(b => b.Type.Id == "RegistrationsBaseUrl");
|
var (registration, _, _) = index!.Resources.First(b => b.Type.Id == "RegistrationsBaseUrl");
|
||||||
|
|
||||||
|
if (!packageBaseAddress.EndsWith('/'))
|
||||||
|
packageBaseAddress += '/';
|
||||||
|
if (!registration.EndsWith('/'))
|
||||||
|
registration += '/';
|
||||||
|
|
||||||
return new NuGetClient(client, new Uri(packageBaseAddress), new Uri(registration));
|
return new NuGetClient(client, new Uri(packageBaseAddress), new Uri(registration));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,13 +4,14 @@ namespace NuGet;
|
|||||||
|
|
||||||
public class PackageSourceMapping(ImmutableArray<PackageSource> sources)
|
public class PackageSourceMapping(ImmutableArray<PackageSource> sources)
|
||||||
{
|
{
|
||||||
private readonly ImmutableDictionary<string, Task<NuGetClient>> _clients = sources.Select(b =>
|
private readonly ImmutableArray<(string pattern, Task<NuGetClient> client)> _clients = [
|
||||||
new KeyValuePair<string, Task<NuGetClient>>(b.Pattern,
|
..sources.Select(b =>
|
||||||
|
(b.Pattern,
|
||||||
NuGetClient.CreateFromIndexUrlAsync(b.Url)))
|
NuGetClient.CreateFromIndexUrlAsync(b.Url)))
|
||||||
.ToImmutableDictionary();
|
];
|
||||||
|
|
||||||
public Task<NuGetClient> GetClientAsync(string packageId) =>
|
public Task<NuGetClient> GetClientAsync(string packageId) =>
|
||||||
_clients.FirstOrDefault(b => packageId.StartsWith(b.Key)).Value;
|
_clients.FirstOrDefault(b => packageId.StartsWith(b.pattern)).client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public record PackageSource(string Pattern, string Url);
|
public record PackageSource(string Pattern, string Url);
|
@@ -7,6 +7,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
|
<PackageType>CringePlugin</PackageType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
115
TestPlugin/packages.lock.json
Normal file
115
TestPlugin/packages.lock.json
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"net8.0-windows7.0": {
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.91.0.1, )",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"NLog": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[5.3.4, )",
|
||||||
|
"resolved": "5.3.4",
|
||||||
|
"contentHash": "gLy7+O1hEYJXIlcTr1/VWjGXrZTQFZzYNO18IWasD64pNwz0BreV+nHLxWKXWZzERRzoKnsk2XYtwLkTVk7J1A=="
|
||||||
|
},
|
||||||
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.*, )",
|
||||||
|
"resolved": "1.205.24",
|
||||||
|
"contentHash": "cgzWJWflVITp+fY5OPgffcoJ08KL5YHMQrMwaDAkUxfRwPgTzU8qOADsrMqq25vXsEbznU1DzNWwTPviYYi7UA==",
|
||||||
|
"dependencies": {
|
||||||
|
"SharpDX": "4.2.0-keen-cringe",
|
||||||
|
"protobuf-net": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dnlib": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.4.0",
|
||||||
|
"contentHash": "cKHI720q+zfEEvzklWVGt6B0TH3AibAyJbpUJl4U6KvTP13tycfnqJpkGHRZ/oQ45BTIoIxIwltHIJVDN+iCqQ=="
|
||||||
|
},
|
||||||
|
"NuGet.Frameworks": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "6.11.1",
|
||||||
|
"contentHash": "plTZ3ariSWQVsFn2mk83SsdmSg1VpgIMTSZpP/eSE/NNQF02p+M9ItxAYeUZBMX+cQ2nFkSwxQRJ0/fkaV9Hbg=="
|
||||||
|
},
|
||||||
|
"NuGet.Versioning": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "6.11.1",
|
||||||
|
"contentHash": "YNn3BB71F+guJW42TbAhGcMh3gpyqFMZcPVD9pm5vcvGivTALtRely/VCPWQQ6JQ5PfwIrjPaJMO7VnqyeK3rg=="
|
||||||
|
},
|
||||||
|
"protobuf-net": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "1.0.0",
|
||||||
|
"contentHash": "kTGOK0E87473sOImOjgZOnz3kTC2aMLffoRWQLYNuBLJnwNNmjanF9IkevZ9Q7yYLeABQfcF3BpeepuMntMVNw=="
|
||||||
|
},
|
||||||
|
"SharpDX": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.2.0-keen-cringe",
|
||||||
|
"contentHash": "LaJN3h1Gi1FWVdef2I5WtOH9gwzKCBniH0CragarbkN2QheYY6Lqm+91PcOfp1w/4wdVb+k8Kjv3sO393Tphtw=="
|
||||||
|
},
|
||||||
|
"System.Buffers": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.5.1",
|
||||||
|
"contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
|
||||||
|
},
|
||||||
|
"System.Numerics.Vectors": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "4.5.0",
|
||||||
|
"contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ=="
|
||||||
|
},
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": {
|
||||||
|
"type": "Transitive",
|
||||||
|
"resolved": "6.0.0",
|
||||||
|
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
|
||||||
|
},
|
||||||
|
"cringebootstrap.abstractions": {
|
||||||
|
"type": "Project"
|
||||||
|
},
|
||||||
|
"cringeplugins": {
|
||||||
|
"type": "Project",
|
||||||
|
"dependencies": {
|
||||||
|
"NLog": "[5.3.4, )",
|
||||||
|
"NuGet": "[1.0.0, )",
|
||||||
|
"SharedCringe": "[1.0.0, )",
|
||||||
|
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )",
|
||||||
|
"dnlib": "[4.4.0, )"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nuget": {
|
||||||
|
"type": "Project",
|
||||||
|
"dependencies": {
|
||||||
|
"NuGet.Frameworks": "[6.11.1, )",
|
||||||
|
"NuGet.Versioning": "[6.11.1, )"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sharedcringe": {
|
||||||
|
"type": "Project",
|
||||||
|
"dependencies": {
|
||||||
|
"CringeBootstrap.Abstractions": "[1.0.0, )",
|
||||||
|
"NLog": "[5.3.4, )",
|
||||||
|
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"net8.0-windows7.0/win-x64": {
|
||||||
|
"ImGui.NET.DirectX": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[1.91.0.1, )",
|
||||||
|
"resolved": "1.91.0.1",
|
||||||
|
"contentHash": "PpW1gQ9g97h6Hm/h/tkSBOmsBYgGwN8wKNmlJomcQFD/zRY1HPkJZz18XRSfRLHPmH2eeh4hhhZv1KHug7dF9g==",
|
||||||
|
"dependencies": {
|
||||||
|
"System.Buffers": "4.5.1",
|
||||||
|
"System.Numerics.Vectors": "4.5.0",
|
||||||
|
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user