Skip to content

Commit b53bf34

Browse files
authored
Merge pull request #30 from Microsoft/develop
Release 2.1
2 parents eba1f4a + 0dea1db commit b53bf34

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

UnitySetup/UnitySetup.psd1

Lines changed: 2 additions & 2 deletions
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.0'
17+
ModuleVersion = '2.1'
1818

1919
# Supported PSEditions
2020
# CompatiblePSEditions = @()
@@ -61,7 +61,7 @@ RequiredModules = @(
6161
# RequiredAssemblies = @()
6262

6363
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
64-
ScriptsToProcess = @("UnitySetupInit.ps1")
64+
ScriptsToProcess = @()
6565

6666
# Type files (.ps1xml) to be loaded when importing this module
6767
# TypesToProcess = @()

UnitySetup/UnitySetup.psm1

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
# Licensed under the MIT License.
33
Import-Module powershell-yaml -Force -ErrorAction Stop
44

5+
[Flags()]
6+
enum UnitySetupComponentType
7+
{
8+
Setup = (1 -shl 0)
9+
Documentation = (1 -shl 1)
10+
StandardAssets = (1 -shl 2)
11+
ExampleProject = (1 -shl 3)
12+
Metro = (1 -shl 4)
13+
UWP_IL2CPP = (1 -shl 5)
14+
Android = (1 -shl 6)
15+
iOS = (1 -shl 7)
16+
AppleTV = (1 -shl 8)
17+
Facebook = (1 -shl 9)
18+
Linux = (1 -shl 10)
19+
Mac = (1 -shl 11)
20+
Vuforia = (1 -shl 12)
21+
WebGL = (1 -shl 13)
22+
Windows_IL2CPP = (1 -shl 14)
23+
All = (-1)
24+
}
25+
526
class UnitySetupInstaller
627
{
728
[UnitySetupComponentType] $ComponentType
@@ -228,6 +249,7 @@ function Find-UnitySetupInstaller
228249
function Install-UnitySetupInstance
229250
{
230251
[CmdletBinding()]
252+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function')]
231253
param(
232254
[parameter(ValueFromPipeline=$true)]
233255
[UnitySetupInstaller[]] $Installers,
@@ -236,7 +258,11 @@ function Install-UnitySetupInstance
236258
[string]$Destination,
237259

238260
[parameter(Mandatory=$false)]
239-
[string]$Cache = [io.Path]::Combine($env:USERPROFILE, ".unitysetup")
261+
[string]$Cache = [io.Path]::Combine($env:USERPROFILE, ".unitysetup"),
262+
263+
[parameter(Mandatory=$false)]
264+
[ValidateSet('Open','RunAs')]
265+
[string]$Verb
240266
)
241267

242268
process
@@ -299,10 +325,19 @@ function Install-UnitySetupInstance
299325
$installer = $localInstallers[$i]
300326
$destination = $localDestinations[$i]
301327

302-
$args = @("/S", "/D=$($localDestinations[$i])")
328+
$startProcessArgs = @{
329+
'FilePath' = $installer;
330+
'ArgumentList' = @("/S", "/D=$($localDestinations[$i])");
331+
'PassThru' = $true;
332+
}
333+
334+
if($Verb)
335+
{
336+
$startProcessArgs['Verb'] = $Verb
337+
}
303338

304339
$spinnerIndex = 0
305-
$process = Start-Process -FilePath $installer -ArgumentList $args -PassThru
340+
$process = Start-Process @startProcessArgs
306341
while(!$process.HasExited)
307342
{
308343
Write-Host "`rInstalling $installer to $destination - $($spins[$spinnerIndex++ % $spins.Length])" -NoNewline
@@ -496,7 +531,7 @@ function Get-UnityProjectInstance
496531
#>
497532
function Start-UnityEditor
498533
{
499-
[CmdletBinding(DefaultParameterSetName="Context")]
534+
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName="Context")]
500535
param(
501536
[parameter(Mandatory=$false, ValueFromPipeline = $true, ParameterSetName='Projects')]
502537
[parameter(Mandatory=$true, ValueFromPipeline = $true, ParameterSetName='ProjectsLatest')]
@@ -665,7 +700,11 @@ function Start-UnityEditor
665700
$setProcessArgs['ArgumentList'] = $unityArgs
666701
}
667702

668-
Write-Verbose "Starting $editor $unityArgs"
703+
if(-not $PSCmdlet.ShouldProcess("$editor $unityArgs", "Start-Process"))
704+
{
705+
continue
706+
}
707+
669708
$process = Start-Process @setProcessArgs
670709
if( $Wait )
671710
{

UnitySetup/UnitySetupInit.ps1

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)