From 994f11d8922ee7658feccc2d6e8aede37c359309 Mon Sep 17 00:00:00 2001 From: JoC0de <53140583+JoC0de@users.noreply.github.com> Date: Sun, 27 Oct 2024 01:50:40 +0200 Subject: [PATCH] allow installing packages that reference netstandard0.0 as framework --- .../Assets/Tests/Editor/NuGetTests.cs | 15 +++++++++++++++ .../Editor/TargetFrameworkResolver.cs | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs b/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs index ff80e4cd..7d11003c 100644 --- a/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs +++ b/src/NuGetForUnity.Tests/Assets/Tests/Editor/NuGetTests.cs @@ -584,6 +584,21 @@ public void InstallBouncyCastleTest([Values] InstallMode installMode) Assert.That(dllFilePath, Does.Exist.IgnoreDirectories); } + [Test] + public void InstallPackageWith00DependencyTest() + { + ConfigureNugetConfig(InstallMode.ApiV3Only); + + var packageWith00Dependency = new NugetPackageIdentifier("Microsoft.ML.OnnxRuntime", "1.19.2") { IsManuallyInstalled = true }; + var expectedDependency = new NugetPackageIdentifier("Microsoft.ML.OnnxRuntime.Managed", "1.19.2"); + + NugetPackageInstaller.InstallIdentifier(packageWith00Dependency); + + // Microsoft.ML.OnnxRuntime depends on Microsoft.ML.OnnxRuntime.Managed, so they should both be installed + Assert.That(InstalledPackagesManager.InstalledPackages, Does.Contain(packageWith00Dependency)); + Assert.That(InstalledPackagesManager.InstalledPackages, Does.Contain(expectedDependency)); + } + [Test] [TestCase("1.0.0-rc1", "1.0.0")] [TestCase("1.0.0-rc1", "1.0.0-rc2")] diff --git a/src/NuGetForUnity/Editor/TargetFrameworkResolver.cs b/src/NuGetForUnity/Editor/TargetFrameworkResolver.cs index a69ca4c4..b7b0ebd1 100644 --- a/src/NuGetForUnity/Editor/TargetFrameworkResolver.cs +++ b/src/NuGetForUnity/Editor/TargetFrameworkResolver.cs @@ -55,6 +55,7 @@ internal static class TargetFrameworkResolver new TargetFrameworkSupport("net35", null, DotnetVersionCompatibilityLevel.NetFramework46Or48), new TargetFrameworkSupport("net20", null, DotnetVersionCompatibilityLevel.NetFramework46Or48), new TargetFrameworkSupport("net11", null, DotnetVersionCompatibilityLevel.NetFramework46Or48), + new TargetFrameworkSupport("net00", null, DotnetVersionCompatibilityLevel.NetFramework46Or48), // .net standard new TargetFrameworkSupport( @@ -102,6 +103,11 @@ internal static class TargetFrameworkResolver null, DotnetVersionCompatibilityLevel.NetStandard20Or21, DotnetVersionCompatibilityLevel.NetFramework46Or48), + new TargetFrameworkSupport( + "netstandard00", + null, + DotnetVersionCompatibilityLevel.NetStandard20Or21, + DotnetVersionCompatibilityLevel.NetFramework46Or48), // fallback if there is one with empty string new TargetFrameworkSupport(string.Empty),