-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyProject.ps1
157 lines (132 loc) · 4.81 KB
/
MyProject.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<#
.SYNOPSIS
Example Unreal Project powershell script
.DESCRIPTION
Automates common operations needed for developing Unreal projects outside of the Unreal Editor.
This is akin to a `Makefile` in a Linux project, allowing you to define common tasks, such as
cooking & building the project.
Copy this file in to the root of your project then rename and adapt for your project.
The commands provided here serve as a useful starting point & reference for some common UE commands for
building on Windows.
In powershell, run the following for help on usage syntax:
Get-Help -Full .\MyProject.ps1
.PARAMETER Action
Which operation to perform.
Cook - Cook project content. Required to run the game outside the editor.
CookAndBuild - Cook and build the project and write the game files into `Builds` for a standalone version.
Zip - Takes the latest build project and zips it up as the given `-Version`.
Profile - Starts Unreal Insights for profiling
PythonScript - Executes a python script in this project via UE's python environment (requires `-Script`).
#>
param (
[Parameter(Mandatory = $true)]
[String]$Action,
[Parameter(Mandatory = $false)]
[String]$Version,
[Parameter(Mandatory = $false)]
[String]$Script
)
### Review these common variables for your project. ###
# Unreal installation directory.
$UeDir = "C:\Program Files\Epic Games\UE_5.5"
# Your project name. Should match the .uproject file name.
$ProjectName = "MyProject"
# Where your project lives. We assume this file is in it root.
$ProjectDir = $PSScriptRoot
# The editor version we use for commands.
$EditorCmd = "$UeDir\Engine\Binaries\Win64\UnrealEditor-Win64-DebugGame-Cmd.exe"
$DateTime = Get-Date -Format "yyyy.MM.dd-HH.mm.ss"
if ($Action -eq "Cook")
{
Start-Process `
-FilePath "$EditorCmd" `
-ArgumentList (
"`"$ProjectDir\$ProjectName.uproject`" -run=Cook -TargetPlatform=Windows -unversioned -fileopenlog",
"-abslog=`"$UeDir\Engine\Programs\AutomationTool\Saved\Cook-$DateTime.txt`" -stdout -CrashForUAT",
"-unattended -NoLogTimes",
"-UTF8Output"
) `
-NoNewWindow -Wait
Write-Output "-------------------"
Write-Output " Cook complete "
Write-Output "-------------------"
}
elseif ($Action -eq "CookAndBuild")
{
Start-Process `
-FilePath "$UeDir\Engine\Build\BatchFiles\RunUAT.bat" `
-ArgumentList (
"-ScriptsForProject=`"$ProjectDir\$ProjectName.uproject`"",
"Turnkey -command=VerifySdk -platform=Win64 -UpdateIfNeeded -EditorIO",
"-EditorIOPort=54155 -project=`"$ProjectDir\$ProjectName.uproject`" BuildCookRun",
"-nop4 -utf8output -nocompileeditor -skipbuildeditor -cook",
"-project=`"$ProjectDir\$ProjectName.uproject`" -target=$ProjectName",
"-unrealexe=`"$UeDir\Engine\Binaries\Win64\$EditorExe`"",
"-platform=Win64 -installed -stage -archive -package -build -clean -pak -iostore ",
"-compressed -prereqs -archivedirectory=`"$ProjectDir/Builds`" -clientconfig=Development",
"-nocompile -nocompileuat"
) `
-NoNewWindow -Wait
Write-Output "-------------------"
Write-Output " Build complete "
Write-Output "-------------------"
}
elseif ($Action -eq "Zip")
{
if ( [string]::IsNullOrEmpty($Version))
{
Write-Host "Cannot zip without a version string (-Version)"
exit 1
}
$ZipPath = "$ProjectDir\Builds\$ProjectName_$Version.zip"
if (Test-Path $ZipPath)
{
Write-Output "Cannot zip. $ZipPath already exists"
exit 1
}
$ToCompress = "$ProjectDir\Builds\Windows"
if (-not (Test-Path $ToCompress))
{
Write-Output "Cannot zip. Build $ToCompress does not exist"
exit 1
}
Write-Output "Compressing to: $ZipPath"
Compress-Archive -Path $ToCompress -DestinationPath $ZipPath
Write-Output "-------------------"
Write-Output " Zip complete "
Write-Output "-------------------"
}
elseif ($Action -eq "Profile")
{
Start-Process -Path "$UeDir\Engine\Binaries\Win64\UnrealInsights.exe"
Write-Output "-------------------------------"
Write-Output " Unreal Insights started"
Write-Output "-------------------------------"
}
elseif ($Action -eq "PythonScript") {
$Script = "$ProjectDir\$Script"
if ( [string]::IsNullOrEmpty($Script))
{
Write-Host "Cannot run python script without a script file (-Script)"
exit 1
}
if (-Not (Test-Path -Path $Script)) {
Write-Error "File not found (-Script): $Script"
exit 1
}
Start-Process `
-FilePath "$EditorCmd" `
-ArgumentList (
"$ProjectDir\$ProjectName.uproject",
"-unattended",
"-run=pythonscript",
"-script=$Script"
)`
-NoNewWindow -Wait
}
else
{
Write-Output "Unrecognized usage"
Write-Output ""
Get-Help "$ProjectDir\$ProjectName.ps1" -Full
}