From 2896c8ea023d4d44af5058c5b2ae31287e982dbb Mon Sep 17 00:00:00 2001 From: Winfried Baumann Date: Thu, 17 Mar 2022 17:42:56 +0100 Subject: [PATCH 01/11] added linux support --- .../SeekersOfEditors/LinuxSeekerOfEditors.cs | 53 +++++++++++++++++++ .../SeekersOfEditors/SeekerOfEditors.cs | 5 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs diff --git a/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs new file mode 100644 index 0000000..31b4bd9 --- /dev/null +++ b/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs @@ -0,0 +1,53 @@ +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Xml.Linq; +using Cake.Core; +using Cake.Core.Diagnostics; +using Cake.Core.IO; +using Cake.Unity.Version; +using System.Text.RegularExpressions; + +[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")] +namespace Cake.Unity.SeekersOfEditors +{ + internal class LinuxSeekerOfEditors : SeekerOfEditors + { + private readonly IFileSystem fileSystem; + private readonly Regex VersionRegex = new Regex("(?\\d+)\\.(?\\d+)\\.(?\\d+)(?\\w)(?\\d+)"); + + public LinuxSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log, IFileSystem fileSystem) + : base(environment, globber, log) + { + this.fileSystem = fileSystem; + } + + protected override string[] SearchPatterns => new[] { + "/home/*/Unity/Hub/Editor/*/Editor/Unity" + }; + + protected override UnityVersion DetermineVersion(FilePath editorPath) + { + log.Debug($"Determining version of Unity Editor at path {editorPath}..."); + + var versionMatch = VersionRegex.Match(editorPath.FullPath); + + if(!versionMatch.Success) + { + log.Debug($"Can't find UnityVersion for {editorPath}"); + return null; + } + + var major = int.Parse(versionMatch.Groups["major"].Value); + var minor = int.Parse(versionMatch.Groups["minor"].Value); + var patch = int.Parse(versionMatch.Groups["patch"].Value); + var branch = char.Parse(versionMatch.Groups["branch"].Value); + var build = int.Parse(versionMatch.Groups["build"].Value); + + var unityVersion = new UnityVersion(major, minor, patch, branch, build); + + log.Debug($"Result Unity Editor version (full): {unityVersion}"); + return unityVersion; + } + } +} diff --git a/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs index 944847e..0871197 100644 --- a/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs +++ b/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs @@ -22,7 +22,10 @@ public static SeekerOfEditors GetSeeker(ICakeEnvironment environment, IGlobber g if (environment.Platform.Family == PlatformFamily.OSX) return new OSXSeekerOfEditors(environment, globber, log, fileSystem); - throw new NotSupportedException("Cannot locate Unity Editors. Only Windows and OSX platform is supported."); + if (environment.Platform.Family == PlatformFamily.Linux) + return new LinuxSeekerOfEditors(environment, globber, log, fileSystem); + + throw new NotSupportedException("Cannot locate Unity Editors. Only Windows, OSX and Linux is supported."); } protected SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log) From b796154934bc5056bb2588d3368bcedcb99d9c02 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Mon, 16 May 2022 22:19:59 +0300 Subject: [PATCH 02/11] ignored Rider folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index feff5d3..f71c797 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ [Bb]uild/ *.sln.ide/ /src/.vs +/src/.idea # Build related tools/** From c8d7486620eade0b14023b8d5a9ac2e15c5ed847 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Mon, 16 May 2022 22:20:19 +0300 Subject: [PATCH 03/11] removed .NET Framework 4.6 from target frameworks --- src/Cake.Unity/Cake.Unity.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Unity/Cake.Unity.csproj b/src/Cake.Unity/Cake.Unity.csproj index ab8680e..5573335 100644 --- a/src/Cake.Unity/Cake.Unity.csproj +++ b/src/Cake.Unity/Cake.Unity.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net46 + netstandard2.0 true true 1591;1573 From aea9f4d4140b958278853e7218d50b96e534542b Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Mon, 16 May 2022 22:34:19 +0300 Subject: [PATCH 04/11] assembly info file for InternalsVisibleTo attribute --- src/Cake.Unity/AssemblyInfo.cs | 3 +++ src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs | 7 +------ src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) create mode 100644 src/Cake.Unity/AssemblyInfo.cs diff --git a/src/Cake.Unity/AssemblyInfo.cs b/src/Cake.Unity/AssemblyInfo.cs new file mode 100644 index 0000000..528a117 --- /dev/null +++ b/src/Cake.Unity/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")] diff --git a/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs index 31b4bd9..72d6468 100644 --- a/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs +++ b/src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs @@ -1,14 +1,9 @@ -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Xml.Linq; -using Cake.Core; +using Cake.Core; using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Unity.Version; using System.Text.RegularExpressions; -[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")] namespace Cake.Unity.SeekersOfEditors { internal class LinuxSeekerOfEditors : SeekerOfEditors diff --git a/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs index d2be108..6a50d93 100644 --- a/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs +++ b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs @@ -1,13 +1,11 @@ using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using System.Xml.Linq; using Cake.Core; using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Unity.Version; -[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")] namespace Cake.Unity.SeekersOfEditors { internal class OSXSeekerOfEditors : SeekerOfEditors From 8492d0b5ca4d2c8dc1c1e35f005402af0e36c012 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Mon, 16 May 2022 22:36:53 +0300 Subject: [PATCH 05/11] switched tests .net framework from core 3.1 to 6.0 --- src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj index fd8a399..02b5739 100644 --- a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj +++ b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false true From 5fd5e937739823e936220963c3743b22ad01d5a1 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 11:15:17 +0300 Subject: [PATCH 06/11] test highlighting exception with Xcode path restrictions --- .../Cake.Unity.FSharp.Tests.fsproj | 3 +++ .../OSXSeekerOfEditorsTests.fs | 21 +++++++++++++++++++ src/Cake.Unity.sln.DotSettings | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs create mode 100644 src/Cake.Unity.sln.DotSettings diff --git a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj index 02b5739..b1829b8 100644 --- a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj +++ b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj @@ -4,10 +4,12 @@ net6.0 false true + Cake.Unity.Tests + @@ -18,6 +20,7 @@ + diff --git a/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs b/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs new file mode 100644 index 0000000..09a95e3 --- /dev/null +++ b/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs @@ -0,0 +1,21 @@ +module Cake.Unity.Tests.OSXSeekerOfEditorsTests + +open Cake.Core +open Cake.Core.IO +open NUnit.Framework +open Cake.Unity.SeekersOfEditors +open Cake.Testing + +let seek (seeker : OSXSeekerOfEditors) = seeker.Seek () + +[] +let ``seek should not fail on real file system`` () = + let environment = FakeEnvironment PlatformFamily.OSX + let fileSystem = FileSystem () + let globber = Globber (fileSystem, environment) + let log = FakeLog () + + (environment, globber, log, fileSystem) + |> OSXSeekerOfEditors + |> seek + |> ignore diff --git a/src/Cake.Unity.sln.DotSettings b/src/Cake.Unity.sln.DotSettings new file mode 100644 index 0000000..bed39ec --- /dev/null +++ b/src/Cake.Unity.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file From b6837ad999ebb7e92fde88ec40f614eeb0cd5859 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 11:55:32 +0300 Subject: [PATCH 07/11] inconclusive test result for Win platform --- .../OSXSeekerOfEditorsTests.fs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs b/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs index 09a95e3..5a79be9 100644 --- a/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs +++ b/src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs @@ -5,17 +5,24 @@ open Cake.Core.IO open NUnit.Framework open Cake.Unity.SeekersOfEditors open Cake.Testing +open System.Runtime.InteropServices let seek (seeker : OSXSeekerOfEditors) = seeker.Seek () +let runningOnWindows = RuntimeInformation.IsOSPlatform OSPlatform.Windows [] let ``seek should not fail on real file system`` () = - let environment = FakeEnvironment PlatformFamily.OSX - let fileSystem = FileSystem () - let globber = Globber (fileSystem, environment) - let log = FakeLog () - (environment, globber, log, fileSystem) - |> OSXSeekerOfEditors - |> seek - |> ignore + if runningOnWindows then + Assert.Inconclusive () + + else + let environment = FakeEnvironment PlatformFamily.OSX + let fileSystem = FileSystem () + let globber = Globber (fileSystem, environment) + let log = FakeLog () + + (environment, globber, log, fileSystem) + |> OSXSeekerOfEditors + |> seek + |> ignore From 7ffe48016038b39751d3ca6cc8aa165ea7e712eb Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 12:06:21 +0300 Subject: [PATCH 08/11] limited MacOS editor seek to Unity Hub folder structure --- src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs index 6a50d93..8adfbcc 100644 --- a/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs +++ b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs @@ -18,7 +18,7 @@ public OSXSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeL this.fileSystem = fileSystem; } - protected override string[] SearchPatterns => new[] {"/Applications/**/Unity*.app/Contents/MacOS/Unity"}; + protected override string[] SearchPatterns => new[] {"/Applications/Unity/Hub/Editor/*/Unity.app/Contents/MacOS/Unity"}; protected override UnityVersion DetermineVersion(FilePath editorPath) { From a97a426edc568078d94f8e8b15de9f91646586b5 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 12:40:17 +0300 Subject: [PATCH 09/11] Revert "switched tests .net framework from core 3.1 to 6.0" This reverts commit 8492d0b5ca4d2c8dc1c1e35f005402af0e36c012. --- src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj index b1829b8..463cf0f 100644 --- a/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj +++ b/src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj @@ -1,7 +1,7 @@ - net6.0 + netcoreapp3.1 false true Cake.Unity.Tests From 363a53e1b7efa89ae53162756e0bb1bca343db9e Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 12:58:01 +0300 Subject: [PATCH 10/11] renamed AssemblyInfo.cs -> AssemblyAttributes.cs --- src/Cake.Unity/{AssemblyInfo.cs => AssemblyAttributes.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Cake.Unity/{AssemblyInfo.cs => AssemblyAttributes.cs} (100%) diff --git a/src/Cake.Unity/AssemblyInfo.cs b/src/Cake.Unity/AssemblyAttributes.cs similarity index 100% rename from src/Cake.Unity/AssemblyInfo.cs rename to src/Cake.Unity/AssemblyAttributes.cs From bf0b2e5b1a9c1087f72cf0544b95c9b5bc48a9c2 Mon Sep 17 00:00:00 2001 From: Anatoliy Kolesnick Date: Tue, 17 May 2022 13:13:26 +0300 Subject: [PATCH 11/11] removed net46 from nuspec --- nuspec/nuget/Cake.Unity.nuspec | 3 --- 1 file changed, 3 deletions(-) diff --git a/nuspec/nuget/Cake.Unity.nuspec b/nuspec/nuget/Cake.Unity.nuspec index 2bf49ad..7c7fab9 100644 --- a/nuspec/nuget/Cake.Unity.nuspec +++ b/nuspec/nuget/Cake.Unity.nuspec @@ -19,8 +19,5 @@ - - -