Skip to content

Commit c574015

Browse files
authored
Merge pull request #46 from Microsoft/release/2.2
Release/2.2
2 parents b53bf34 + 04c908f commit c574015

File tree

4 files changed

+88
-16
lines changed

4 files changed

+88
-16
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
This PowerShell module contains tools for managing and automating your Unity installs and projects.
44

55
## Builds
6-
[![Build status](https://ci.appveyor.com/api/projects/status/m7ykg9s8gw23fn6h?svg=true)](https://ci.appveyor.com/project/jwittner/unitysetup-powershell)
6+
7+
### Master
8+
[![Build status](https://ci.appveyor.com/api/projects/status/m7ykg9s8gw23fn6h/branch/master?svg=true)](https://ci.appveyor.com/project/jwittner/unitysetup-powershell/branch/master)
79

810
The `master` branch is automatically built and deployed to the [PowerShell Gallery](https://www.powershellgallery.com/packages/UnitySetup).
911

12+
### Develop
13+
[![Build status](https://ci.appveyor.com/api/projects/status/m7ykg9s8gw23fn6h/branch/develop?svg=true)](https://ci.appveyor.com/project/jwittner/unitysetup-powershell/branch/develop)
14+
15+
The `develop` branch is automatically built and deployed as a prerelease module to the [PowerShell Gallery](https://www.powershellgallery.com/packages/UnitySetup).
1016

1117
## Installation
1218

UnitySetup/UnitySetup.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
RootModule = 'UnitySetup'
1515

1616
# Version number of this module.
17-
ModuleVersion = '2.1'
17+
ModuleVersion = '2.2'
1818

1919
# Supported PSEditions
2020
# CompatiblePSEditions = @()
@@ -79,6 +79,7 @@ FunctionsToExport = @(
7979
'Get-UnitySetupInstance',
8080
'Install-UnitySetupInstance',
8181
'Select-UnitySetupInstance',
82+
'Uninstall-UnitySetupInstance',
8283
'Start-UnityEditor'
8384
)
8485
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.

UnitySetup/UnitySetup.psm1

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class UnityProjectInstance
6969
}
7070
}
7171

72-
class UnityVersion
72+
class UnityVersion : System.IComparable
7373
{
7474
[int] $Major;
7575
[int] $Minor;
@@ -100,6 +100,14 @@ class UnityVersion
100100
}
101101
}
102102

103+
[int] CompareTo([object]$obj)
104+
{
105+
if($null -eq $obj) { return 1 }
106+
if($obj -isnot [UnityVersion]) { throw "Object is not a UnityVersion"}
107+
108+
return [UnityVersion]::Compare($this, $obj)
109+
}
110+
103111
static [int] Compare([UnityVersion]$a, [UnityVersion]$b)
104112
{
105113
if($a.Major -lt $b.Major) { return -1 }
@@ -182,10 +190,15 @@ function Find-UnitySetupInstaller
182190
'f' { $searchPages += "https://unity3d.com/get-unity/download/archive" }
183191
'b' { $searchPages += "https://unity3d.com/unity/beta/unity$Version" }
184192
'p' {
185-
$webResult = Invoke-WebRequest "https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)"
186-
$searchPages += $webResult.Links | Where-Object { $_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" } | ForEach-Object {
187-
"https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)&page=$($Matches[1])"
188-
}
193+
$patchPage = "https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)"
194+
$searchPages += $patchPage
195+
196+
$webResult = Invoke-WebRequest $patchPage
197+
$searchPages += $webResult.Links | Where-Object {
198+
$_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" -and $Matches[1] -gt 1
199+
} | ForEach-Object {
200+
"https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)&page=$($Matches[1])"
201+
}
189202
}
190203
}
191204

@@ -196,7 +209,7 @@ function Find-UnitySetupInstaller
196209
$_ -match "$($installerTemplates[[UnitySetupComponentType]::Setup])$"
197210
}
198211

199-
if($null -eq $prototypeLink) { break }
212+
if($null -ne $prototypeLink) { break }
200213
}
201214

202215
if($null -eq $prototypeLink)
@@ -357,6 +370,51 @@ function Install-UnitySetupInstance
357370
}
358371
}
359372

373+
<#
374+
.Synopsis
375+
Uninstall Unity Setup Instances
376+
.DESCRIPTION
377+
Uninstall the specified Unity Setup Instances
378+
.PARAMETER Instance
379+
What instances of UnitySetup should be uninstalled
380+
.EXAMPLE
381+
Get-UnitySetupInstance | Uninstall-UnitySetupInstance
382+
#>
383+
function Uninstall-UnitySetupInstance {
384+
[CmdletBinding(SupportsShouldProcess)]
385+
param(
386+
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
387+
[UnitySetupInstance[]] $Instances
388+
)
389+
390+
process {
391+
foreach ( $setupInstance in $Instances ) {
392+
$uninstaller = Get-ChildItem "$($setupInstance.Path)" -Filter 'Uninstall.exe' -Recurse |
393+
Select-Object -First 1 -ExpandProperty FullName
394+
395+
if($null -eq $uninstaller) {
396+
Write-Error "Could not find Uninstaller.exe under $($setupInstance.Path)"
397+
continue
398+
}
399+
400+
$startProcessArgs = @{
401+
'FilePath' = $uninstaller;
402+
'PassThru' = $true;
403+
'Wait' = $true;
404+
'ErrorAction' = 'Stop';
405+
'ArgumentList' = @("/S");
406+
}
407+
408+
if( -not $PSCmdlet.ShouldProcess("$uninstaller", "Start-Process")) { continue }
409+
410+
$process = Start-Process @startProcessArgs
411+
if ( $process.ExitCode -ne 0 ) {
412+
Write-Error "Uninstaller quit with non-zero exit code"
413+
}
414+
}
415+
}
416+
}
417+
360418
<#
361419
.Synopsis
362420
Get the Unity versions installed
@@ -554,6 +612,10 @@ function Start-UnityEditor
554612
[parameter(Mandatory=$false)]
555613
[string]$ExecuteMethod,
556614
[parameter(Mandatory=$false)]
615+
[string[]]$ExportPackage,
616+
[parameter(Mandatory=$false)]
617+
[string]$CreateProject,
618+
[parameter(Mandatory=$false)]
557619
[string]$OutputPath,
558620
[parameter(Mandatory=$false)]
559621
[string]$LogFile,
@@ -640,12 +702,14 @@ function Start-UnityEditor
640702
}
641703

642704
$sharedArgs = @()
705+
if( $CreateProject ) { $sharedArgs += "-createProject", $CreateProject }
643706
if( $ExecuteMethod ) { $sharedArgs += "-executeMethod", $ExecuteMethod }
644707
if( $OutputPath ) { $sharedArgs += "-buildOutput", $OutputPath }
645708
if( $LogFile ) { $sharedArgs += "-logFile", $LogFile }
646709
if( $BuildTarget ) { $sharedArgs += "-buildTarget", $BuildTarget }
647710
if( $BatchMode ) { $sharedArgs += "-batchmode" }
648711
if( $Quit ) { $sharedArgs += "-quit" }
712+
if( $ExportPackage ) { $sharedArgs += "-exportPackage","$ExportPackage" }
649713

650714
$instanceArgs = @()
651715
foreach( $p in $projectInstances ) {
@@ -689,7 +753,9 @@ function Start-UnityEditor
689753
continue
690754
}
691755

692-
$unityArgs = $sharedArgs + $instanceArgs[$i]
756+
# clone the shared args list
757+
$unityArgs = $sharedArgs | ForEach-Object { $_ }
758+
if( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] }
693759
$setProcessArgs = @{
694760
'FilePath' = $editor;
695761
'PassThru' = $true;
@@ -711,9 +777,9 @@ function Start-UnityEditor
711777
$process.WaitForExit();
712778
if( $process.ExitCode -ne 0 )
713779
{
714-
if( $LogFile )
780+
if( $LogFile -and (Test-Path $LogFile -Type Leaf) )
715781
{
716-
Get-Content $LogFile | Write-Information
782+
Get-Content $LogFile | ForEach-Object { Write-Information -MessageData $_ -Tags 'Logs' }
717783
}
718784

719785
Write-Error "Unity quit with non-zero exit code"

appveyor.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
version: '{build}'
22
pull_requests:
33
do_not_increment_build_number: true
4-
branches:
5-
only:
6-
- master
7-
- develop
84
environment:
95
NugetAPIKey:
106
secure: zvkaZiaBXVko+3ZzuSb7W6DTUJmHX98XgEhKs28SnGD+4TM3gzhPxVnNWSmBhXEx
@@ -37,4 +33,7 @@ for:
3733
- master
3834
build_script:
3935
- ps: .\build.ps1 -Revision "$env:APPVEYOR_BUILD_NUMBER"
40-
36+
-
37+
branches:
38+
only:
39+
- develop

0 commit comments

Comments
 (0)