From b4b957e71707d2149efa8c282ad83a637fcb3e0e Mon Sep 17 00:00:00 2001 From: Mikhail Dunaev Date: Thu, 16 Mar 2023 02:13:27 +0100 Subject: [PATCH 1/3] Add support of custom "-buildTarget" parameter for unity --- src/Cake.Unity/UnityEditorArguments.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Cake.Unity/UnityEditorArguments.cs b/src/Cake.Unity/UnityEditorArguments.cs index ec716aa..2fef0f1 100644 --- a/src/Cake.Unity/UnityEditorArguments.cs +++ b/src/Cake.Unity/UnityEditorArguments.cs @@ -60,6 +60,11 @@ public class UnityEditorArguments /// public BuildTarget? BuildTarget { get; set; } + /// + /// Allows the selection of an active build target before loading a project (with string). + /// + public string CustomBuildTarget { get; set; } + /// /// Build a 32-bit standalone Windows player (for example, -buildWindowsPlayer path/to/your/build.exe). /// @@ -328,6 +333,18 @@ internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBui .Append("-buildTarget") .Append(BuildTarget.Value.ToString()); + if (CustomBuildTarget != null) + { + builder + .Append("-buildTarget") + .AppendQuoted(CustomBuildTarget); + } + + if (CustomBuildTarget != null && BuildTarget.HasValue) + { + throw new Exception("Providing both BuildTarget and CustomBuildTarget is not supported."); + } + if (BuildWindowsPlayer != null) builder .Append("-buildWindowsPlayer") From fbbc045ff30b692ff4ff84a54562c4081f338f30 Mon Sep 17 00:00:00 2001 From: Mikhail Dunaev Date: Thu, 16 Mar 2023 02:13:52 +0100 Subject: [PATCH 2/3] Add GDK and PS5 build targets --- src/Cake.Unity/Arguments/BuildTarget.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Cake.Unity/Arguments/BuildTarget.cs b/src/Cake.Unity/Arguments/BuildTarget.cs index d5d5d4e..9917b84 100644 --- a/src/Cake.Unity/Arguments/BuildTarget.cs +++ b/src/Cake.Unity/Arguments/BuildTarget.cs @@ -23,5 +23,10 @@ public enum BuildTarget N3DS, tvOS, PSM, + + GameCoreXboxSeries, + GameCoreXboxOne, + GameCoreScarlett, + PS5, } } From b4648bab44381be4a515954485fa38a7fd249c4e Mon Sep 17 00:00:00 2001 From: Mikhail Dunaev Date: Thu, 16 Mar 2023 03:00:11 +0100 Subject: [PATCH 3/3] Add tests --- .../UnityEditorArgumentsTests.fs | 12 ++++++++++++ src/Cake.Unity/UnityEditorArguments.cs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Cake.Unity.FSharp.Tests/UnityEditorArgumentsTests.fs b/src/Cake.Unity.FSharp.Tests/UnityEditorArgumentsTests.fs index 8a18f60..14cdcfa 100644 --- a/src/Cake.Unity.FSharp.Tests/UnityEditorArgumentsTests.fs +++ b/src/Cake.Unity.FSharp.Tests/UnityEditorArgumentsTests.fs @@ -1,5 +1,7 @@ module Cake.Unity.Tests.UnityEditorArgumentsTests +open System +open Cake.Unity.Arguments open FSharp.Interop.Dynamic open FsUnit.TopLevelOperators open NUnit.Framework @@ -21,6 +23,11 @@ let setExecuteMethod value (arguments : UnityEditorArguments) = arguments.ExecuteMethod <- value arguments +let setCustomBuildTarget value (arguments : UnityEditorArguments) = + arguments.CustomBuildTarget <- value + arguments + + [] let ``CLI arguments with enabled BatchMode should contain "-batchmode"`` () = () |> UnityEditorArguments |> setBatchMode true |> commandLineArguments |> should haveSubstring "-batchmode" @@ -48,3 +55,8 @@ let ``default BatchMode value should be true`` () = [] let ``default Quit value should be true`` () = UnityEditorArguments().Quit |> should equal true + +[] +let ``CLI arguments with Custom argument "CustomBuildTarget" of value "PS5" should contain "-buildTarget PS5"`` () = + () |> UnityEditorArguments |> setCustomBuildTarget "PS5" |> commandLineArguments |> should haveSubstring "-buildTarget PS5" + diff --git a/src/Cake.Unity/UnityEditorArguments.cs b/src/Cake.Unity/UnityEditorArguments.cs index 2fef0f1..329c38e 100644 --- a/src/Cake.Unity/UnityEditorArguments.cs +++ b/src/Cake.Unity/UnityEditorArguments.cs @@ -337,12 +337,12 @@ internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBui { builder .Append("-buildTarget") - .AppendQuoted(CustomBuildTarget); + .Append(CustomBuildTarget); } if (CustomBuildTarget != null && BuildTarget.HasValue) { - throw new Exception("Providing both BuildTarget and CustomBuildTarget is not supported."); + throw new ArgumentException("Providing both BuildTarget and CustomBuildTarget is not supported."); } if (BuildWindowsPlayer != null)