diff --git a/nuspec/nuget/Cake.Unity.nuspec b/nuspec/nuget/Cake.Unity.nuspec index e774983..7e5a363 100644 --- a/nuspec/nuget/Cake.Unity.nuspec +++ b/nuspec/nuget/Cake.Unity.nuspec @@ -9,7 +9,7 @@ Cake AddIn that extends Cake with ability to execute the Unity Editor as a command line utility. https://github.com/cake-contrib/Cake.Unity/blob/master/LICENSE https://github.com/cake-contrib/Cake.Unity/ - https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png + https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png false Copyright (c) Cake Contributions 2014 - Present Cake, Script, Build, Unity diff --git a/setup.cake b/setup.cake index 59b79ae..9e9fc53 100644 --- a/setup.cake +++ b/setup.cake @@ -1,4 +1,4 @@ -#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&version=0.3.0-unstable0452&prerelease +#load nuget:?package=Cake.Recipe&version=1.0.0 Environment.SetVariableNames(); @@ -22,4 +22,4 @@ ToolSettings.SetToolSettings(context: Context, testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); -Build.Run(); +Build.RunDotNetCore(); diff --git a/src/Cake.Unity.sln b/src/Cake.Unity.sln index 0b7414f..c1ccc47 100644 --- a/src/Cake.Unity.sln +++ b/src/Cake.Unity.sln @@ -1,14 +1,10 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.168 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.202 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Unity", "Cake.Unity\Cake.Unity.csproj", "{0222DDD2-3716-4E19-854F-EB36D04268D0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Unity.Tests", "Cake.Unity.Tests\Cake.Unity.Tests.csproj", "{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Cake.Unity.FSharp.Tests", "Cake.Unity.FSharp.Tests\Cake.Unity.FSharp.Tests.fsproj", "{240E476F-324F-4489-B7A9-98A8EBD28C2A}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -19,14 +15,6 @@ Global {0222DDD2-3716-4E19-854F-EB36D04268D0}.Debug|Any CPU.Build.0 = Debug|Any CPU {0222DDD2-3716-4E19-854F-EB36D04268D0}.Release|Any CPU.ActiveCfg = Release|Any CPU {0222DDD2-3716-4E19-854F-EB36D04268D0}.Release|Any CPU.Build.0 = Release|Any CPU - {9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Release|Any CPU.Build.0 = Release|Any CPU - {240E476F-324F-4489-B7A9-98A8EBD28C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {240E476F-324F-4489-B7A9-98A8EBD28C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {240E476F-324F-4489-B7A9-98A8EBD28C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {240E476F-324F-4489-B7A9-98A8EBD28C2A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Cake.Unity/Arguments/AssetServerUpdate.cs b/src/Cake.Unity/Arguments/AssetServerUpdate.cs new file mode 100644 index 0000000..644aab0 --- /dev/null +++ b/src/Cake.Unity/Arguments/AssetServerUpdate.cs @@ -0,0 +1,39 @@ +namespace Cake.Unity.Arguments +{ + public class AssetServerUpdate + { + public string IP { get; } + public int? Port { get; } + public string ProjectName { get; } + public string Username { get; } + public string Password { get; } + public string Revision { get; } + + public AssetServerUpdate(string ip, string projectName, string userName, string password) + { + IP = ip; + ProjectName = projectName; + Username = userName; + Password = password; + } + + public AssetServerUpdate(string ip, int port, string projectName, string userName, string password) + : this(ip, projectName, userName, password) + { + Port = port; + } + + public AssetServerUpdate(string ip, string projectName, string userName, string password, string revision) + : this(ip, projectName, userName, password) + { + Revision = revision; + } + + public AssetServerUpdate(string ip, int port, string projectName, string userName, string password, string revision) + : this(ip, projectName, userName, password) + { + Port = port; + Revision = revision; + } + } +} diff --git a/src/Cake.Unity/Arguments/DefaultPlatformTextureFormat.cs b/src/Cake.Unity/Arguments/DefaultPlatformTextureFormat.cs new file mode 100644 index 0000000..f6660d4 --- /dev/null +++ b/src/Cake.Unity/Arguments/DefaultPlatformTextureFormat.cs @@ -0,0 +1,12 @@ +namespace Cake.Unity.Arguments +{ + public enum DefaultPlatformTextureFormat + { + dxt, + pvrtc, + atc, + etc, + etc2, + astc + } +} diff --git a/src/Cake.Unity/Arguments/ExportPackage.cs b/src/Cake.Unity/Arguments/ExportPackage.cs new file mode 100644 index 0000000..6fe8ac6 --- /dev/null +++ b/src/Cake.Unity/Arguments/ExportPackage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Cake.Unity.Arguments +{ + public class ExportPackage + { + public string[] AssetPaths { get; set; } + public string PackageName { get; set; } + } +} diff --git a/src/Cake.Unity/Arguments/ForceGLCore.cs b/src/Cake.Unity/Arguments/ForceGLCore.cs new file mode 100644 index 0000000..7e0bcc1 --- /dev/null +++ b/src/Cake.Unity/Arguments/ForceGLCore.cs @@ -0,0 +1,21 @@ +namespace Cake.Unity.Arguments +{ + public enum ForceGLCore + { + Auto = 0, + v32 = 32, + v33 = 33, + v40 = 40, + v41 = 41, + v42 = 42, + v43 = 43, + v44 = 44, + v45 = 45 + } + + internal static class ForceGLCoreExtension + { + public static string Render(this ForceGLCore version) => + version == ForceGLCore.Auto ? "" : ((int) version).ToString(); + } +} diff --git a/src/Cake.Unity/Arguments/ForceGLES.cs b/src/Cake.Unity/Arguments/ForceGLES.cs new file mode 100644 index 0000000..c83bbfc --- /dev/null +++ b/src/Cake.Unity/Arguments/ForceGLES.cs @@ -0,0 +1,16 @@ +namespace Cake.Unity.Arguments +{ + public enum ForceGLES + { + Auto = 0, + v30 = 30, + v31 = 31, + v32 = 32 + } + + internal static class ForceGLESExtension + { + public static string Render(this ForceGLES version) => + version == ForceGLES.Auto ? "" : ((int)version).ToString(); + } +} diff --git a/src/Cake.Unity/Arguments/StackTraceLogType.cs b/src/Cake.Unity/Arguments/StackTraceLogType.cs new file mode 100644 index 0000000..4b70104 --- /dev/null +++ b/src/Cake.Unity/Arguments/StackTraceLogType.cs @@ -0,0 +1,9 @@ +namespace Cake.Unity.Arguments +{ + public enum StackTraceLogType + { + None, + ScriptOnly, + Full + } +} diff --git a/src/Cake.Unity/Cake.Unity.csproj b/src/Cake.Unity/Cake.Unity.csproj index 5ce480c..5c15974 100644 --- a/src/Cake.Unity/Cake.Unity.csproj +++ b/src/Cake.Unity/Cake.Unity.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs new file mode 100644 index 0000000..3dc5c62 --- /dev/null +++ b/src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs @@ -0,0 +1,48 @@ +using System.Linq; +using System.Xml.Linq; +using Cake.Core; +using Cake.Core.Diagnostics; +using Cake.Core.IO; +using Cake.Unity.Version; + +namespace Cake.Unity.SeekersOfEditors +{ + internal class OSXSeekerOfEditors : SeekerOfEditors + { + public OSXSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log) + : base(environment, globber, log) + { } + + protected override string SearchPattern => "/Applications/**/Unity*.app/Contents/MacOS/Unity"; + + protected override UnityVersion DetermineVersion(FilePath editorPath) + { + log.Debug($"Determining version of Unity Editor at path {editorPath}..."); + + var version = UnityVersionFromInfoPlist(editorPath); + + if (version == null) + { + log.Debug($"Can't find UnityVersion for {editorPath}"); + return null; + } + + var unityVersion = UnityVersion.Parse(version); + + log.Debug($"Result Unity Editor version (full): {unityVersion}"); + return unityVersion; + } + + private static string UnityVersionFromInfoPlist(FilePath editorPath) => + XElement + .Load(PlistPath(editorPath)) + .Descendants() + .SkipWhile((element) => element.Value != "CFBundleVersion") + .Skip(1) + .FirstOrDefault() + ?.Value; + + private static string PlistPath(FilePath editorPath) => + editorPath.FullPath.Replace("/MacOS/Unity", "/Info.plist"); + } +} diff --git a/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs new file mode 100644 index 0000000..82cd382 --- /dev/null +++ b/src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Cake.Core; +using Cake.Core.Diagnostics; +using Cake.Core.IO; +using Cake.Unity.Version; + +namespace Cake.Unity.SeekersOfEditors +{ + internal abstract class SeekerOfEditors + { + protected readonly ICakeEnvironment environment; + private readonly IGlobber globber; + protected readonly ICakeLog log; + + public static SeekerOfEditors GetSeeker(ICakeEnvironment environment, IGlobber globber, ICakeLog log) + { + if (environment.Platform.Family == PlatformFamily.Windows) + return new WindowsSeekerOfEditors(environment, globber, log); + + if (environment.Platform.Family == PlatformFamily.OSX) + return new OSXSeekerOfEditors(environment, globber, log); + + throw new NotSupportedException("Cannot locate Unity Editors. Only Windows and OSX platform is supported."); + } + + protected SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log) + { + this.environment = environment; + this.globber = globber; + this.log = log; + } + + public IReadOnlyCollection Seek() + { + var searchPattern = SearchPattern; + + log.Debug("Searching for available Unity Editors..."); + log.Debug("Search pattern: {0}", searchPattern); + var candidates = globber.GetFiles(searchPattern).ToList(); + + log.Debug("Found {0} candidates.", candidates.Count); + log.Debug(string.Empty); + + var editors = + from candidatePath in candidates + let version = DetermineVersion(candidatePath) + where version != null + select new UnityEditorDescriptor(version, candidatePath); + + return editors.ToList(); + } + + protected abstract string SearchPattern { get; } + + protected abstract UnityVersion DetermineVersion(FilePath editorPath); + } +} diff --git a/src/Cake.Unity/SeekerOfEditors.cs b/src/Cake.Unity/SeekersOfEditors/WindowsSeekerOfEditors.cs similarity index 71% rename from src/Cake.Unity/SeekerOfEditors.cs rename to src/Cake.Unity/SeekersOfEditors/WindowsSeekerOfEditors.cs index 6360ae3..befc0a7 100644 --- a/src/Cake.Unity/SeekerOfEditors.cs +++ b/src/Cake.Unity/SeekersOfEditors/WindowsSeekerOfEditors.cs @@ -1,50 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; +using System.Diagnostics; using System.Linq; using Cake.Core; using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Unity.Version; -namespace Cake.Unity +namespace Cake.Unity.SeekersOfEditors { - internal class SeekerOfEditors + internal class WindowsSeekerOfEditors : SeekerOfEditors { - private readonly ICakeEnvironment environment; - private readonly IGlobber globber; - private readonly ICakeLog log; - - public SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log) - { - this.environment = environment; - this.globber = globber; - this.log = log; - } + public WindowsSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log) + : base(environment, globber, log) + { } private string ProgramFiles => environment.GetSpecialPath(SpecialPath.ProgramFiles).FullPath; + protected override string SearchPattern => $"{ProgramFiles}/*Unity*/**/Editor/Unity.exe"; - public IReadOnlyCollection Seek() - { - var searchPattern = $"{ProgramFiles}/*Unity*/**/Editor/Unity.exe"; - - log.Debug("Searching for available Unity Editors..."); - log.Debug("Search pattern: {0}", searchPattern); - var candidates = globber.GetFiles(searchPattern).ToList(); - - log.Debug("Found {0} candidates.", candidates.Count); - log.Debug(string.Empty); - - var editors = - from candidatePath in candidates - let version = DetermineVersion(candidatePath) - where version != null - select new UnityEditorDescriptor(version, candidatePath); - - return editors.ToList(); - } - - private UnityVersion DetermineVersion(FilePath editorPath) + protected override UnityVersion DetermineVersion(FilePath editorPath) { log.Debug("Determining version of Unity Editor at path {0}...", editorPath); diff --git a/src/Cake.Unity/UnityAliases.cs b/src/Cake.Unity/UnityAliases.cs index 88d8959..e9b91b4 100644 --- a/src/Cake.Unity/UnityAliases.cs +++ b/src/Cake.Unity/UnityAliases.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Cake.Core; @@ -7,8 +6,8 @@ using Cake.Core.Diagnostics; using Cake.Core.IO; using Cake.Unity.Platforms; +using Cake.Unity.SeekersOfEditors; using Cake.Unity.Version; -using static Cake.Core.PlatformFamily; using static Cake.Unity.Version.UnityReleaseStage; namespace Cake.Unity @@ -334,9 +333,6 @@ select editor [CakeNamespaceImport("Cake.Unity.Version")] public static IReadOnlyCollection FindUnityEditors(this ICakeContext context) { - if (context.Environment.Platform.Family != Windows) - throw new NotSupportedException("Cannot locate Unity Editors. Only Windows platform is supported."); - if (unityEditorsCache != null) { context.Log.Debug("Already searched for Unity Editors. Using cached results."); @@ -345,7 +341,7 @@ public static IReadOnlyCollection FindUnityEditors(this I return unityEditorsCache = - new SeekerOfEditors(context.Environment, context.Globber, context.Log) + SeekerOfEditors.GetSeeker(context.Environment, context.Globber, context.Log) .Seek(); } diff --git a/src/Cake.Unity/UnityEditorArguments.cs b/src/Cake.Unity/UnityEditorArguments.cs index 8b7bbf4..73c8cc5 100644 --- a/src/Cake.Unity/UnityEditorArguments.cs +++ b/src/Cake.Unity/UnityEditorArguments.cs @@ -13,6 +13,11 @@ public class UnityEditorArguments { private readonly ExpandoObject customArguments = new ExpandoObject(); + /// + /// Force an update of the project in the Asset Server given by IP:port. The port is optional, and if not given it is assumed to be the standard one (10733). It is advisable to use this command in conjunction with the -projectPath argument to ensure you are working with the correct project. If you don’t give a project name, then the command line uses the last project opened by Unity. If no project exists at the path -projectPath gives, then the command line creates one automatically. + /// + public AssetServerUpdate AssetServerUpdate { get; set; } + /// /// Run Unity in batch mode. You should always use this in conjunction with the other command line arguments, because it ensures no pop-up windows appear and eliminates the need for any human intervention. When an exception occurs during execution of the script code, the Asset server updates fail, or other operations fail, Unity immediately exits with return code 1. /// Note that in batch mode, Unity sends a minimal version of its log output to the console. However, the Log Files still contain the full log information. You cannot open a project in batch mode while the Editor has the same project open; only a single instance of Unity can run at a time. @@ -20,6 +25,36 @@ public class UnityEditorArguments /// public bool BatchMode { get; set; } = true; + /// + /// Build a 32-bit standalone Linux player (for example, -buildLinux32Player path/to/your/build). + /// + public FilePath BuildLinux32Player { get; set; } + + /// + /// Build a 64-bit standalone Linux player (for example, -buildLinux64Player path/to/your/build) + /// + public FilePath BuildLinux64Player { get; set; } + + /// + /// Build a combined 32-bit and 64-bit standalone Linux player (for example, -buildLinuxUniversalPlayer path/to/your/build) + /// + public FilePath BuildLinuxUniversalPlayer { get; set; } + + /// + /// Build a 32-bit standalone Mac OSX player (for example, -buildOSXPlayer path/to/your/build.app) + /// + public FilePath BuildOSXPlayer { get; set; } + + /// + /// Build a 64-bit standalone Mac OSX player (for example, -buildOSX64Player path/to/your/build.app) + /// + public FilePath BuildOSX64Player { get; set; } + + /// + /// Build a combined 32-bit and 64-bit standalone Mac OSX player (for example, -buildOSXUniversalPlayer path/to/your/build.app) + /// + public FilePath BuildOSXUniversalPlayer { get; set; } + /// /// Allows the selection of an active build target before loading a project. /// @@ -30,16 +65,118 @@ public class UnityEditorArguments /// public FilePath BuildWindowsPlayer { get; set; } + /// + /// Build a 64-bit standalone Windows player (for example, -buildWindows64Player path/to/your/build.exe) + /// + public FilePath BuildWindows64Player { get; set; } + + /// + /// Detailed debugging feature. StackTraceLogging allows you to allow detailed logging. (for example, -stackTraceLogType Full) + /// + public StackTraceLogType? StackTraceLogType { get; set; } + + /// + /// Connect to the specified Cache Server on startup, overriding any configuration stored in the Editor Preferences. + /// Set string as host:port + /// + public string CacheServerIPAddress { get; set; } + + /// + /// Create an empty project at the given path. + /// + public FilePath CreateProject { get; set; } + + /// + /// Filter editor tests by categories. Separate test categories with a comma. + /// + public string EditorTestsCategories { get; set; } + + /// + /// Filter editor tests by names. Separate test names with a comma. + /// + public string EditorTestsFilter { get; set; } + + /// + /// Path location to place the result file. If the path is a folder, the command line uses a default file name. If not specified, it places the results in the project’s root folder. + /// + public FilePath EditorTestsResultFile { get; set; } + /// /// Execute the static method as soon as Unity opens the project, and after the optional Asset server update is complete. You can use this to do tasks such as continous integration, performing Unit Tests, making builds or preparing data. To return an error from the command line process, either throw an exception which causes Unity to exit with return code 1, or call EditorApplication.Exit with a non-zero return code. To pass parameters, add them to the command line and retrieve them inside the function using System.Environment.GetCommandLineArgs. To use -executeMethod, you need to place the enclosing script in an Editor folder. The method you execute must be defined as static. /// public string ExecuteMethod { get; set; } + /// + /// Export a package, given a path (or set of given paths). Asset paths are set relative to the Unity project root. + /// Currently, this option only exports whole folders at a time. You normally need to use this command with the -projectPath argument. + /// + public ExportPackage ExportPackage { get; set; } + + /// + /// Windows only. Make the Editor use Direct3D 11 for rendering. Normally the graphics API depends on Player settings(typically defaults to D3D11). + /// + public bool ForceD3D11 { get; set; } + + /// + /// MacOS only. When using Metal, make the Editor use a particular GPU device by passing it the index of that GPU. + /// + public bool ForceDeviceIndex { get; set; } + + /// + /// MacOS only. Make the Editor use Metal as the default graphics API. + /// + public bool ForceGfxMetal { get; set; } + + /// + /// Make the Editor use OpenGL core profile for rendering. + /// + public ForceGLCore? ForceGLCore { get; set; } + + /// + /// Windows only. Make the Editor use OpenGL for Embedded Systems for rendering. + /// + public ForceGLES? ForceGLES { get; set; } + + /// + /// Used with -force-glcoreXY to prevent checking for additional OpenGL extensions, allowing it to run between platforms with the same code paths. + /// + public bool ForceClamped { get; set; } + + /// + /// Make the Editor run as if there is a free Unity license on the machine, even if a Unity Pro license is installed. + /// + public bool ForceFree { get; set; } + + /// + /// MacOS only. When using Metal, make the Editor use a low power device. + /// + public bool ForceLowPowerDevice { get; set; } + + /// + /// Import the given package. No import dialog is shown. + /// + public FilePath ImportPackage { get; set; } + /// /// Specify where the Editor or Windows/Linux/OSX standalone log file are written. If the path is ommitted, OSX and Linux will write output to the console. Windows uses the path %LOCALAPPDATA%\Unity\Editor\Editor.log as a default. /// public FilePath LogFile { get; set; } + /// + /// When running in batch mode, do not initialize the graphics device at all. This makes it possible to run your automated workflows on machines that don’t even have a GPU (automated workflows only work when you have a window in focus, otherwise you can’t send simulated input commands). Note that -nographics does not allow you to bake GI, because Enlighten requires GPU acceleration. + /// + public bool NoGraphics { get; set; } + + /// + /// Disables the Unity Package Manager. + /// + public bool NoUPM { get; set; } + + /// + /// Enter a password into the log-in form during activation of the Unity Editor. + /// + public string Password { get; set; } + /// /// Open the project at the given path. /// @@ -50,6 +187,46 @@ public class UnityEditorArguments /// public bool Quit { get; set; } = true; + /// + /// Return the currently active license to the license server. Please allow a few seconds before the license file is removed, because Unity needs to communicate with the license server. + /// + public bool ReturnLicense { get; set; } + + /// + /// Run Editor tests from the project. This argument requires the projectPath, and it’s good practice to run it with batchmode argument. quit is not required, because the Editor automatically closes down after the run is finished. + /// + public bool RunEditorTests { get; set; } + + /// + /// Activate Unity with the specified serial key. It is good practice to pass the -batchmode and -quit arguments as well, in order to quit Unity when done, if using this for automated activation of Unity. Please allow a few seconds before the license file is created, because Unity needs to communicate with the license server. Make sure that license file folder exists, and has appropriate permissions before running Unity with this argument. If activation fails, see the Editor.log for info. + /// + public string Serial { get; set; } + + /// + /// Supported only on Android. Sets the default texture compression to the desired format before importing a texture or building the project. This is so you don’t have to import the texture again with the format you want. + /// + public DefaultPlatformTextureFormat? SetDefaultPlatformTextureFormat { get; set; } + + /// + /// Prevent Unity from displaying the dialog that appears when a Standalone Player crashes. This argument is useful when you want to run the Player in automated builds or tests, where you don’t want a dialog prompt to obstruct automation. + /// + public bool SilentCrashes { get; set; } + + /// + /// Enter a username into the log-in form during activation of the Unity Editor. + /// + public string Username { get; set; } + + /// + /// Specify a space-separated list of assembly names as parameters for Unity to ignore on automatic updates. Pass empty array to ignore all assemblies. + /// + public string[] DisableAssemblyUpdater { get; set; } + + /// + /// Use this command line option to specify that APIUpdater should run when Unity is launched in batch mode. Omitting this command line argument when launching Unity in batch mode results in APIUpdater not running which can lead to compiler errors. Note that in versions prior to 2017.2 there’s no way to not run APIUpdater when Unity is launched in batch mode. + /// + public bool AcceptAPIUpdate { get; set; } + /// /// Custom arguments which can further be processed in Unity Editor script by calling System.Environment.GetCommandLineArgs method. /// They are supplied among other arguments in format "--key=value". @@ -86,10 +263,57 @@ public class UnityEditorArguments internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBuilder builder, ICakeEnvironment environment) { + if (AssetServerUpdate != null) + { + builder.Append("-assetServerUpdate"); + if (AssetServerUpdate.Port.HasValue) + builder.Append(AssetServerUpdate.IP + ":" + AssetServerUpdate.Port.Value.ToString()); + else + builder.Append(AssetServerUpdate.IP); + builder.Append(AssetServerUpdate.ProjectName); + builder.Append(AssetServerUpdate.Username); + builder.Append(AssetServerUpdate.Password); + if (AssetServerUpdate.Revision != null) + { + builder.Append("r"); + builder.Append(AssetServerUpdate.Revision); + } + } + if (BatchMode) builder .Append("-batchmode"); + if (BuildLinux32Player != null) + builder + .Append("-buildLinux32Player") + .AppendQuoted(BuildLinux32Player.MakeAbsolute(environment).FullPath); + + if (BuildLinux64Player != null) + builder + .Append("-buildLinux64Player") + .AppendQuoted(BuildLinux64Player.MakeAbsolute(environment).FullPath); + + if (BuildLinuxUniversalPlayer != null) + builder + .Append("-buildLinuxUniversalPlayer") + .AppendQuoted(BuildLinuxUniversalPlayer.MakeAbsolute(environment).FullPath); + + if (BuildOSXPlayer != null) + builder + .Append("-buildOSXPlayer") + .AppendQuoted(BuildOSXPlayer.MakeAbsolute(environment).FullPath); + + if (BuildOSX64Player != null) + builder + .Append("-buildOSX64Player") + .AppendQuoted(BuildOSX64Player.MakeAbsolute(environment).FullPath); + + if (BuildOSXUniversalPlayer != null) + builder + .Append("-buildOSXUniversalPlayer") + .AppendQuoted(BuildOSXUniversalPlayer.MakeAbsolute(environment).FullPath); + if (BuildTarget.HasValue) builder .Append("-buildTarget") @@ -100,16 +324,99 @@ internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBui .Append("-buildWindowsPlayer") .AppendQuoted(BuildWindowsPlayer.MakeAbsolute(environment).FullPath); + if (BuildWindows64Player != null) + builder + .Append("-buildWindows64Player") + .AppendQuoted(BuildWindows64Player.MakeAbsolute(environment).FullPath); + + if (StackTraceLogType.HasValue) + builder + .Append("-stackTraceLogType") + .Append(StackTraceLogType.Value.ToString()); + + if (CacheServerIPAddress != null) + builder + .Append("-CacheServerIPAddress") + .Append(CacheServerIPAddress); + + if (CreateProject != null) + builder + .Append("-createProject") + .AppendQuoted(CreateProject.MakeAbsolute(environment).FullPath); + + if (EditorTestsCategories != null) + builder + .Append("-editorTestsCategories") + .Append(EditorTestsCategories); + + if (EditorTestsFilter != null) + builder + .Append("-editorTestsFilter") + .Append(EditorTestsFilter); + + if (EditorTestsResultFile != null) + builder + .Append("-editorTestsResultFile") + .AppendQuoted(EditorTestsResultFile.MakeAbsolute(environment).FullPath); + if (ExecuteMethod != null) builder .Append("-executeMethod") .Append(ExecuteMethod); + if (ExportPackage != null && ExportPackage.AssetPaths != null && ExportPackage.PackageName != null) + { + builder.Append("-exportPackage"); + foreach (var exportPackageAssetPath in ExportPackage.AssetPaths) + builder.AppendQuoted(exportPackageAssetPath); + builder.AppendQuoted(ExportPackage.PackageName); + } + + if (ForceD3D11) + builder.Append("-force-d3d11"); + + if (ForceDeviceIndex) + builder.Append("-force-device-index"); + + if (ForceGfxMetal) + builder.Append("-force-gfx-metal"); + + if (ForceGLCore.HasValue) + builder.Append("-force-glcore" + ForceGLCore.Value.Render()); + + if (ForceGLES.HasValue) + builder.Append("-force-gles" + ForceGLES.Value.Render()); + + if (ForceClamped) + builder.Append("-force-clamped"); + + if (ForceFree) + builder.Append("-force-free"); + + if (ForceLowPowerDevice) + builder.Append("-force-low-power-device"); + + if (ImportPackage != null) + builder + .Append("-importPackage") + .AppendQuoted(ImportPackage.MakeAbsolute(environment).FullPath); + if (LogFile != null) builder .Append("-logFile") .AppendQuoted(LogFile.FullPath); + if (NoGraphics) + builder.Append("-nographics"); + + if (NoUPM) + builder.Append("-noUpm"); + + if (Password != null) + builder + .Append("-password") + .Append(Password); //may be use AppendQuoted instead?? + if (ProjectPath != null) builder .Append("-projectPath") @@ -119,6 +426,40 @@ internal ProcessArgumentBuilder CustomizeCommandLineArguments(ProcessArgumentBui builder .Append("-quit"); + if (ReturnLicense) + builder.Append("-returnlicense"); + + if (RunEditorTests && ProjectPath != null) + builder.Append("-runEditorTests"); + + if (Serial != null) + builder + .Append("-serial") + .Append(Serial); + + if (SetDefaultPlatformTextureFormat.HasValue) + builder + .Append("-setDefaultPlatformTextureFormat") + .Append(SetDefaultPlatformTextureFormat.Value.ToString()); + + if (SilentCrashes) + builder.Append("-silent-crashes"); + + if (Username != null) + builder + .Append("-username") + .Append(Username); //may be use AppendQuoted instead?? + + if (DisableAssemblyUpdater != null) + { + builder.Append("-disable-assembly-updater"); + foreach (var assembly in DisableAssemblyUpdater) + builder.AppendQuoted(assembly); + } + + if (AcceptAPIUpdate) + builder.Append("-accept-apiupdate"); + foreach (var customArgument in customArguments) builder .Append($"--{customArgument.Key}={customArgument.Value}"); diff --git a/src/Cake.Unity/Version/UnityVersion.cs b/src/Cake.Unity/Version/UnityVersion.cs index c937983..4fba3dc 100644 --- a/src/Cake.Unity/Version/UnityVersion.cs +++ b/src/Cake.Unity/Version/UnityVersion.cs @@ -42,5 +42,26 @@ public override string ToString() => SuffixCharacter.HasValue && SuffixNumber.HasValue ? $"{Year}.{Stream}.{Update}{SuffixCharacter}{SuffixNumber}" : $"{Year}.{Stream}.{Update}"; + + public static UnityVersion Parse(string s) + { + var version = s.Split('.'); + int charPos = (int)FirstNotDigit(version[2]); + + return new UnityVersion( + year: int.Parse(version[0]), + stream: int.Parse(version[1]), + update: int.Parse(version[2].Substring(0, charPos)), + suffixCharacter: version[2][charPos], + suffixNumber: int.Parse(version[2].Substring(charPos + 1))); + } + + private static int? FirstNotDigit(string str) + { + for (int i = 0; i < str.Length; ++i) + if (!char.IsDigit(str[i])) + return i; + return null; + } } } diff --git a/tools/packages.config b/tools/packages.config index 0501888..f27ab48 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,4 +1,4 @@ - +