Skip to content

Commit 0645b4c

Browse files
committed
Merge branch 'release/0.5.1'
2 parents 336b08b + e5e9942 commit 0645b4c

File tree

6 files changed

+320
-28
lines changed

6 files changed

+320
-28
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ The API is not in any way final and will change.
88

99
Examples
1010
-------
11+
12+
```csharp
13+
#addin Cake.Unity
14+
15+
Task("Default").Does(() =>
16+
UnityEditor(
17+
2018, 3,
18+
new UnityEditorArguments
19+
{
20+
ProjectPath = "A:/UnityProject",
21+
BuildWindowsPlayer = "A:/Build/game.exe",
22+
LogFile = "A:/Build/unity.log",
23+
},
24+
new UnityEditorSettings
25+
{
26+
RealTimeLog = true,
27+
}));
28+
29+
RunTarget("Default");
30+
```
31+
1132
```csharp
1233
#addin Cake.Unity
1334

src/Cake.Unity/SeekerOfEditors.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public IReadOnlyCollection<UnityEditorDescriptor> Seek()
3333
var candidates = globber.GetFiles(searchPattern).ToList();
3434

3535
log.Debug("Found {0} candidates.", candidates.Count);
36+
log.Debug(string.Empty);
3637

3738
var editors =
3839
from candidatePath in candidates
@@ -45,7 +46,6 @@ from candidatePath in candidates
4546

4647
private UnityVersion DetermineVersion(FilePath editorPath)
4748
{
48-
log.Debug(string.Empty);
4949
log.Debug("Determining version of Unity Editor at path {0}...", editorPath);
5050

5151
var fileVersion = FileVersionInfo.GetVersionInfo(editorPath.FullPath);
@@ -54,10 +54,10 @@ private UnityVersion DetermineVersion(FilePath editorPath)
5454

5555
if (year <= 0 || stream <= 0 || update < 0)
5656
{
57-
log.Warning(
58-
"Unity Editor file version {0} at path {1} is incorrect. Expected first two parts to be positive numbers and third one to be non negative.",
59-
$"{year}.{stream}.{update}.{fileVersion.FilePrivatePart}",
60-
editorPath.FullPath);
57+
log.Warning("Unity Editor file version {0} is incorrect.", $"{year}.{stream}.{update}.{fileVersion.FilePrivatePart}");
58+
log.Warning("Expected first two numbers to be positive and third one to be non negative.");
59+
log.Warning("Path: {0}", editorPath.FullPath);
60+
log.Warning(string.Empty);
6161
return null;
6262
}
6363

@@ -69,12 +69,14 @@ private UnityVersion DetermineVersion(FilePath editorPath)
6969
{
7070
var version = new UnityVersion(year, stream, update, suffix.Value.character, suffix.Value.number);
7171
log.Debug("Result Unity Editor version (full): {0}", version);
72+
log.Debug(string.Empty);
7273
return version;
7374
}
7475
else
7576
{
7677
var version = new UnityVersion(year, stream, update);
7778
log.Debug("Result Unity Editor version (short): {0}", version);
79+
log.Debug(string.Empty);
7880
return version;
7981
}
8082
}

src/Cake.Unity/UnityAliases.cs

Lines changed: 168 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static void UnityBuild(this ICakeContext context, DirectoryPath projectPa
2727
tool.Run(context, projectPath, platform);
2828
}
2929

30+
31+
3032
/// <summary>
3133
/// Executes Unity Editor via command-line interface.
3234
/// </summary>
@@ -35,21 +37,183 @@ public static void UnityBuild(this ICakeContext context, DirectoryPath projectPa
3537
/// <example>
3638
/// <code>
3739
/// var unityEditor = FindUnityEditor(2018, 3) ?? throw new Exception("Cannot find Unity Editor 2018.3.");
40+
///
3841
/// UnityEditor(unityEditor.Path, new UnityEditorArguments
3942
/// {
40-
/// BatchMode = true,
4143
/// ProjectPath = "A:/UnityProject",
4244
/// BuildWindowsPlayer = "A:/Build/game.exe",
4345
/// LogFile = "A:/Build/unity.log",
44-
/// Quit = true,
4546
/// });
4647
/// </code>
4748
/// </example>
4849
[CakeMethodAlias]
4950
[CakeAliasCategory("Build")]
50-
public static void UnityEditor(this ICakeContext context, FilePath unityEditorPath, UnityEditorArguments arguments) =>
51+
public static void UnityEditor(this ICakeContext context,
52+
FilePath unityEditorPath, UnityEditorArguments arguments) =>
53+
UnityEditor(context, unityEditorPath, arguments, new UnityEditorSettings());
54+
55+
/// <summary>
56+
/// Executes Unity Editor via command-line interface.
57+
/// </summary>
58+
/// <param name="unityEditorPath">Path to Unity Editor executable.</param>
59+
/// <param name="arguments">Unity Editor command-line arguments.</param>
60+
/// <param name="settings">Settings which affect how Unity Editor should be executed.</param>
61+
/// <example>
62+
/// <code>
63+
/// var unityEditor = FindUnityEditor(2018, 3) ?? throw new Exception("Cannot find Unity Editor 2018.3.");
64+
///
65+
/// UnityEditor(
66+
/// unityEditor.Path,
67+
/// new UnityEditorArguments
68+
/// {
69+
/// ProjectPath = "A:/UnityProject",
70+
/// BuildWindowsPlayer = "A:/Build/game.exe",
71+
/// LogFile = "A:/Build/unity.log",
72+
/// },
73+
/// new UnityEditorSettings
74+
/// {
75+
/// RealTimeLog = true,
76+
/// });
77+
/// </code>
78+
/// </example>
79+
[CakeMethodAlias]
80+
[CakeAliasCategory("Build")]
81+
public static void UnityEditor(this ICakeContext context,
82+
FilePath unityEditorPath, UnityEditorArguments arguments, UnityEditorSettings settings) =>
83+
new UnityEditor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log)
84+
.Run(unityEditorPath, arguments, settings);
85+
86+
/// <summary>
87+
/// Executes Unity Editor via command-line interface.
88+
/// </summary>
89+
/// <param name="unityEditor">Unity Editor descriptor provided by a FindUnityEditor method.</param>
90+
/// <param name="arguments">Unity Editor command-line arguments.</param>
91+
/// <param name="settings">Optional settings which affect how Unity Editor should be executed.</param>
92+
/// <example>
93+
/// <code>
94+
/// UnityEditor(
95+
/// FindUnityEditor(2018, 3) ?? throw new Exception("Cannot find Unity Editor 2018.3."),
96+
/// new UnityEditorArguments
97+
/// {
98+
/// ProjectPath = "A:/UnityProject",
99+
/// BuildWindowsPlayer = "A:/Build/game.exe",
100+
/// LogFile = "A:/Build/unity.log",
101+
/// },
102+
/// new UnityEditorSettings
103+
/// {
104+
/// RealTimeLog = true,
105+
/// });
106+
/// </code>
107+
/// </example>
108+
[CakeMethodAlias]
109+
[CakeAliasCategory("Build")]
110+
public static void UnityEditor(this ICakeContext context,
111+
UnityEditorDescriptor unityEditor, UnityEditorArguments arguments, UnityEditorSettings settings = null) =>
112+
new UnityEditor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log)
113+
.Run(unityEditor, arguments, settings ?? new UnityEditorSettings());
114+
115+
/// <summary>
116+
/// <para>Executes Unity Editor via command-line interface.</para>
117+
/// <para>Determines Unity Editor location automatically by specified version.</para>
118+
/// </summary>
119+
/// <param name="versionYear">Year part of Unity version aka major version.</param>
120+
/// <param name="versionStream">Stream part of Unity version aka minor version.</param>
121+
/// <param name="arguments">Unity Editor command-line arguments.</param>
122+
/// <param name="settings">Optional settings which affect how Unity Editor should be executed.</param>
123+
/// <example>
124+
/// <code>
125+
/// UnityEditor(
126+
/// 2018, 3,
127+
/// new UnityEditorArguments
128+
/// {
129+
/// ProjectPath = "A:/UnityProject",
130+
/// BuildWindowsPlayer = "A:/Build/game.exe",
131+
/// LogFile = "A:/Build/unity.log",
132+
/// },
133+
/// new UnityEditorSettings
134+
/// {
135+
/// RealTimeLog = true,
136+
/// });
137+
/// </code>
138+
/// </example>
139+
[CakeMethodAlias]
140+
[CakeAliasCategory("Build")]
141+
public static void UnityEditor(this ICakeContext context,
142+
int versionYear, int versionStream, UnityEditorArguments arguments, UnityEditorSettings settings = null) =>
51143
new UnityEditor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log)
52-
.Run(unityEditorPath, arguments);
144+
.Run(
145+
context.FindUnityEditor(versionYear, versionStream)
146+
?? throw new Exception($"Failed to locate Unity Editor {versionYear}.{versionStream}. Try to specify it's path explicitly."),
147+
arguments,
148+
settings ?? new UnityEditorSettings());
149+
150+
/// <summary>
151+
/// <para>Executes Unity Editor via command-line interface.</para>
152+
/// <para>Determines Unity Editor location automatically by specified version.</para>
153+
/// </summary>
154+
/// <param name="versionYear">Year part of Unity version aka major version.</param>
155+
/// <param name="arguments">Unity Editor command-line arguments.</param>
156+
/// <param name="settings">Optional settings which affect how Unity Editor should be executed.</param>
157+
/// <example>
158+
/// <code>
159+
/// UnityEditor(
160+
/// 2018,
161+
/// new UnityEditorArguments
162+
/// {
163+
/// ProjectPath = "A:/UnityProject",
164+
/// BuildWindowsPlayer = "A:/Build/game.exe",
165+
/// LogFile = "A:/Build/unity.log",
166+
/// },
167+
/// new UnityEditorSettings
168+
/// {
169+
/// RealTimeLog = true,
170+
/// });
171+
/// </code>
172+
/// </example>
173+
[CakeMethodAlias]
174+
[CakeAliasCategory("Build")]
175+
public static void UnityEditor(this ICakeContext context,
176+
int versionYear, UnityEditorArguments arguments, UnityEditorSettings settings = null) =>
177+
new UnityEditor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log)
178+
.Run(
179+
context.FindUnityEditor(versionYear)
180+
?? throw new Exception($"Failed to locate Unity Editor {versionYear}. Try to specify it's path explicitly."),
181+
arguments,
182+
settings ?? new UnityEditorSettings());
183+
184+
/// <summary>
185+
/// <para>Executes Unity Editor via command-line interface.</para>
186+
/// <para>Determines location of latest available Unity Editor automatically.</para>
187+
/// </summary>
188+
/// <param name="arguments">Unity Editor command-line arguments.</param>
189+
/// <param name="settings">Optional settings which affect how Unity Editor should be executed.</param>
190+
/// <example>
191+
/// <code>
192+
/// UnityEditor(
193+
/// new UnityEditorArguments
194+
/// {
195+
/// ProjectPath = "A:/UnityProject",
196+
/// BuildWindowsPlayer = "A:/Build/game.exe",
197+
/// LogFile = "A:/Build/unity.log",
198+
/// },
199+
/// new UnityEditorSettings
200+
/// {
201+
/// RealTimeLog = true,
202+
/// });
203+
/// </code>
204+
/// </example>
205+
[CakeMethodAlias]
206+
[CakeAliasCategory("Build")]
207+
public static void UnityEditor(this ICakeContext context,
208+
UnityEditorArguments arguments, UnityEditorSettings settings = null) =>
209+
new UnityEditor(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log)
210+
.Run(
211+
context.FindUnityEditor()
212+
?? throw new Exception("Failed to locate Unity Editor. Try to specify it's path explicitly."),
213+
arguments,
214+
settings ?? new UnityEditorSettings());
215+
216+
53217

54218
/// <summary>
55219
/// Locates installed Unity Editor with latest version.

0 commit comments

Comments
 (0)