Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Cake.Unity.FSharp.Tests/UnityEditorArgumentsTests.fs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,6 +23,11 @@ let setExecuteMethod value (arguments : UnityEditorArguments) =
arguments.ExecuteMethod <- value
arguments

let setCustomBuildTarget value (arguments : UnityEditorArguments) =
arguments.CustomBuildTarget <- value
arguments


[<Test>]
let ``CLI arguments with enabled BatchMode should contain "-batchmode"`` () =
() |> UnityEditorArguments |> setBatchMode true |> commandLineArguments |> should haveSubstring "-batchmode"
Expand Down Expand Up @@ -48,3 +55,8 @@ let ``default BatchMode value should be true`` () =
[<Test>]
let ``default Quit value should be true`` () =
UnityEditorArguments().Quit |> should equal true

[<Test>]
let ``CLI arguments with Custom argument "CustomBuildTarget" of value "PS5" should contain "-buildTarget PS5"`` () =
() |> UnityEditorArguments |> setCustomBuildTarget "PS5" |> commandLineArguments |> should haveSubstring "-buildTarget PS5"

5 changes: 5 additions & 0 deletions src/Cake.Unity/Arguments/BuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ public enum BuildTarget
N3DS,
tvOS,
PSM,

GameCoreXboxSeries,
GameCoreXboxOne,
GameCoreScarlett,
PS5,
}
}
17 changes: 17 additions & 0 deletions src/Cake.Unity/UnityEditorArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public class UnityEditorArguments
/// </summary>
public BuildTarget? BuildTarget { get; set; }

/// <summary>
/// Allows the selection of an active build target before loading a project (with string).
/// </summary>
public string CustomBuildTarget { get; set; }

/// <summary>
/// Build a 32-bit standalone Windows player (for example, -buildWindowsPlayer path/to/your/build.exe).
/// </summary>
Expand Down Expand Up @@ -328,6 +333,18 @@ internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBui
.Append("-buildTarget")
.Append(BuildTarget.Value.ToString());

if (CustomBuildTarget != null)
{
builder
.Append("-buildTarget")
.Append(CustomBuildTarget);
}

if (CustomBuildTarget != null && BuildTarget.HasValue)
{
throw new ArgumentException("Providing both BuildTarget and CustomBuildTarget is not supported.");
}

if (BuildWindowsPlayer != null)
builder
.Append("-buildWindowsPlayer")
Expand Down