Skip to content

Commit

Permalink
Merge pull request #156 from OriginalSINe/feature/apiDotNetStandard2.0
Browse files Browse the repository at this point in the history
.NET Standard 2.0 (Support Unity 2018)
  • Loading branch information
jwittner authored Jun 18, 2018
2 parents 1158059 + 0008122 commit d74524f
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions Assets/NuGet/Editor/NugetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -306,6 +306,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<string>();

// go through the library folders in descending order (highest to lowest version)
Expand All @@ -316,7 +318,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;
Expand All @@ -326,11 +343,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);
Expand All @@ -341,11 +368,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);
Expand Down Expand Up @@ -1289,4 +1331,4 @@ public static Texture2D DownloadImage(string url)
return result;
}
}
}
}

0 comments on commit d74524f

Please sign in to comment.