This repository was archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetUnity3D.ps1
More file actions
51 lines (38 loc) · 2.17 KB
/
getUnity3D.ps1
File metadata and controls
51 lines (38 loc) · 2.17 KB
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
<#
Script to install the latest version of Unity3D on agent
#>
$ErrorActionPreference = "Stop"
$archiveContentFile = "$env:TEMP_DIR\content.html"
$dependenciesDir = "$env:DEPENDENCIES_DIR\Unity"
Write-Host "Getting latest version of Unity3D"
# Create the dependencies directory if it does not exist
if(!(Test-Path -Path $dependenciesDir))
{
New-Item -ItemType directory -Path $dependenciesDir | Out-Null
}
# Fetch the download archieve page from unity3d.com
wget -OutFile $archiveContentFile https://unity3d.com/get-unity/download/archive
# Parse out the current version of the Unity3D editor
$regex = "http://netstorage.unity3d.com/unity/[a-z0-9]+/Windows64EditorInstaller/UnitySetup64-[0-9]+\.[0-9]+\.[0-9]+f[0-9]+\.exe"
$currentDownloadLink = Select-String -Path $archiveContentFile -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
$regex = "http://netstorage.unity3d.com/unity/[a-z0-9]+"
$currentRevision = $currentDownloadLink | Select-String -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
$lastSlashPos = $currentRevision.LastIndexOf("/");
$currentRevision = $currentRevision.Substring($lastSlashPos + 1)
$regex = "UnitySetup64-[0-9]+\.[0-9]+\.[0-9]+f[0-9]+"
$currentVersion = $currentDownloadLink | Select-String -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
$regex = "[0-9]+\.[0-9]+\.[0-9]+f[0-9]+"
$currentVersionNumber = $currentVersion | Select-String -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
Remove-Item -Path $archiveContentFile
if(!($currentVersionNumber))
{
Add-AppveyorMessage -Category Error -Message "Cannot obtain the most current version of Unity3D."
$host.SetShouldExit(1)
}
Write-Host "Downloading $currentVersion"
# Download Unity3D editor and Windows build support
wget -OutFile "$env:TEMP_DIR\$currentVersion.exe" $currentDownloadLink
Write-Host "Installing $currentVersion"
# Install Unity3D editor and Windows build support
Start-Process -Wait -FilePath "$env:TEMP_DIR\$currentVersion.exe" -ArgumentList "/S /D=$dependenciesDir"
Add-AppveyorMessage -Category Information -Message "Installed: $currentVersion"