From 6968523029e49ee4ce35a850e7d58cfbbccff239 Mon Sep 17 00:00:00 2001 From: Walter Date: Fri, 4 May 2018 01:03:24 -0400 Subject: [PATCH 1/2] .NET Standard 2.0 (Support Unity 2018) --- Assets/NuGet/Editor/NugetHelper.cs | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Assets/NuGet/Editor/NugetHelper.cs b/Assets/NuGet/Editor/NugetHelper.cs index 0b2a5bf3..20c34568 100644 --- a/Assets/NuGet/Editor/NugetHelper.cs +++ b/Assets/NuGet/Editor/NugetHelper.cs @@ -309,6 +309,8 @@ private static void Clean(NugetPackageIdentifier package) int intDotNetVersion = (int)DotNetVersion; // c //bool using46 = DotNetVersion == ApiCompatibilityLevel.NET_4_6; // NET_4_6 option was added in Unity 5.6 bool using46 = intDotNetVersion == 3; // NET_4_6 = 3 in Unity 5.6 and Unity 2017.1 - use the hard-coded int value to ensure it works in earlier versions of Unity + bool usingStandard2 = intDotNetVersion == 6; // using .net standard 2.0 + var selectedDirectories = new List(); // go through the library folders in descending order (highest to lowest version) @@ -319,7 +321,22 @@ private static void Clean(NugetPackageIdentifier package) // Select the highest .NET library available that is supported // See here: https://docs.nuget.org/ndocs/schema/target-frameworks - if (using46 && directoryName == "net462") + if (usingStandard2 && directoryName == "netstandard2.0") + { + selectedDirectories.Add(directory.FullName); + break; + } + else if (usingStandard2 && directoryName == "netstandard1.6") + { + selectedDirectories.Add(directory.FullName); + break; + } + else if (using46 && directoryName == "net462") + { + selectedDirectories.Add(directory.FullName); + break; + } + else if (usingStandard2 && directoryName == "netstandard1.5") { selectedDirectories.Add(directory.FullName); break; @@ -329,11 +346,21 @@ private static void Clean(NugetPackageIdentifier package) selectedDirectories.Add(directory.FullName); break; } + else if (usingStandard2 && directoryName == "netstandard1.4") + { + selectedDirectories.Add(directory.FullName); + break; + } else if (using46 && directoryName == "net46") { selectedDirectories.Add(directory.FullName); break; } + else if (usingStandard2 && directoryName == "netstandard1.3") + { + selectedDirectories.Add(directory.FullName); + break; + } else if (using46 && directoryName == "net452") { selectedDirectories.Add(directory.FullName); @@ -344,11 +371,26 @@ private static void Clean(NugetPackageIdentifier package) selectedDirectories.Add(directory.FullName); break; } + else if (usingStandard2 && directoryName == "netstandard1.2") + { + selectedDirectories.Add(directory.FullName); + break; + } else if (using46 && directoryName == "net45") { selectedDirectories.Add(directory.FullName); break; } + else if (usingStandard2 && directoryName == "netstandard1.1") + { + selectedDirectories.Add(directory.FullName); + break; + } + else if (usingStandard2 && directoryName == "netstandard1.0") + { + selectedDirectories.Add(directory.FullName); + break; + } else if (using46 && directoryName == "net403") { selectedDirectories.Add(directory.FullName); From 0008122a16df0cee2fe7c1a76dbe6eb4e038f1c2 Mon Sep 17 00:00:00 2001 From: Walter <8096152+OriginalSINe@users.noreply.github.com> Date: Fri, 4 May 2018 01:40:05 -0400 Subject: [PATCH 2/2] Changed from "Unknown" build target to current Changed to use the current build target. May cause issues when switching build targets. Ideally, each build target should store its own set of packages. --- Assets/NuGet/Editor/NugetHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/NuGet/Editor/NugetHelper.cs b/Assets/NuGet/Editor/NugetHelper.cs index 20c34568..bdb62fa3 100644 --- a/Assets/NuGet/Editor/NugetHelper.cs +++ b/Assets/NuGet/Editor/NugetHelper.cs @@ -95,7 +95,7 @@ static NugetHelper() } #if UNITY_5_6_OR_NEWER - DotNetVersion = PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Unknown); + DotNetVersion = PlayerSettings.GetApiCompatibilityLevel(EditorUserBuildSettings.selectedBuildTargetGroup); #else DotNetVersion = PlayerSettings.apiCompatibilityLevel; #endif @@ -1334,4 +1334,4 @@ public static Texture2D DownloadImage(string url) return result; } } -} \ No newline at end of file +}