From 6ba5f7928b858b2fcde5cf03c61a829b67a87b7e Mon Sep 17 00:00:00 2001 From: Robert Onulak Date: Mon, 2 Apr 2018 16:24:10 -0700 Subject: [PATCH 01/20] Support for Mac for Get-UnitySetupInstance. --- UnitySetup/UnitySetup.psm1 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 99af693..fc49176 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -471,11 +471,26 @@ function Get-UnitySetupInstance { [CmdletBinding()] param( [parameter(Mandatory = $false)] - [string[]] $BasePath = @('C:\Program Files*\Unity*', 'C:\Program Files\Unity\Hub\Editor\*') + [string[]] $BasePath ) + # Windows + if ((-not $PSVersionTable.Platform) -or ($PSVersionTable.Platform -eq "Win32NT")) { + if (-not $BasePath) { + $BasePath = @('C:\Program Files*\Unity*', 'C:\Program Files\Unity\Hub\Editor\*') + } + $ivyPath = 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' + } + # Mac or Linux + else { + if (-not $BasePath) { + $BasePath = @('/Applications/Unity*') + } + $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' + } + foreach ( $folder in $BasePath ) { - $path = [io.path]::Combine("$folder", 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml'); + $path = [io.path]::Combine("$folder", $ivyPath); Get-ChildItem $path -Recurse -ErrorAction Ignore | ForEach-Object { From c5438f6c6219949e75b8329049772d90caf82d8e Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Mon, 2 Apr 2018 16:28:16 -0700 Subject: [PATCH 02/20] Redirect standard streams for Start-UnityEditor --- UnitySetup/UnitySetup.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 99af693..fb74bca 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -777,12 +777,18 @@ function Start-UnityEditor { # clone the shared args list $unityArgs = $sharedArgs | ForEach-Object { $_ } if ( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] } + $setProcessArgs = @{ 'FilePath' = $editor; 'PassThru' = $true; 'ErrorAction' = 'Stop'; + 'RedirectStandardOutput' = New-TemporaryFile; + 'RedirectStandardError' = New-TemporaryFile; } + Write-Verbose "Redirecting standard output to $($setProcessArgs['RedirectStandardOutput'])" + Write-Verbose "Redirecting standard error to $($setProcessArgs['RedirectStandardError'])" + if ($unityArgs -and $unityArgs.Length -gt 0) { $setProcessArgs['ArgumentList'] = $unityArgs } From 692c6f95ab0da77218135d9e1159b93617c88138 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Mon, 2 Apr 2018 16:51:01 -0700 Subject: [PATCH 03/20] No more write-host for Install-UnitySetupInstance --- UnitySetup/UnitySetup.psm1 | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 99af693..505d274 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -317,7 +317,6 @@ function Find-UnitySetupInstaller { #> function Install-UnitySetupInstance { [CmdletBinding()] - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function')] param( [parameter(ValueFromPipeline = $true)] [UnitySetupInstaller[]] $Installers, @@ -379,14 +378,13 @@ function Install-UnitySetupInstance { Start-BitsTransfer -Source $downloadSource -Destination $downloadDest } - $spins = @('|', '/', '-', '\') for ($i = 0; $i -lt $localInstallers.Length; $i++) { $installer = $localInstallers[$i] $destination = $localDestinations[$i] $startProcessArgs = @{ 'FilePath' = $installer; - 'ArgumentList' = @("/S", "/D=$($localDestinations[$i])"); + 'ArgumentList' = @("/S", "/D=$destination"); 'PassThru' = $true; } @@ -394,19 +392,17 @@ function Install-UnitySetupInstance { $startProcessArgs['Verb'] = $Verb } - $spinnerIndex = 0 + Write-Verbose "$(Get-Date): Installing $installer to $destination." $process = Start-Process @startProcessArgs - while (!$process.HasExited) { - Write-Host "`rInstalling $installer to $destination - $($spins[$spinnerIndex++ % $spins.Length])" -NoNewline - Start-Sleep -Milliseconds 100 - } + if( $process ) { + $process.WaitForExit() - if ( $process.ExitCode -ne 0) { - Write-Host "`bFailed." - Write-Error "Installing $installer failed with exit code: $($process.ExitCode)" - } - else { - Write-Host "`bSucceeded." + if ( $process.ExitCode -ne 0) { + Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)" + } + else { + Write-Verbose "$(Get-Date): Succeeded." + } } } } @@ -816,11 +812,11 @@ function Start-UnityEditor { ) | ForEach-Object { $alias = Get-Alias -Name $_.Name -ErrorAction 'SilentlyContinue' - if( -not $alias ) { + if ( -not $alias ) { Write-Verbose "Creating new alias $($_.Name) for $($_.Value)" New-Alias @_ } - elseif( $alias.ModuleName -eq 'UnitySetup' ) { + elseif ( $alias.ModuleName -eq 'UnitySetup' ) { Write-Verbose "Setting alias $($_.Name) to $($_.Value)" Set-Alias @_ } From e624b8e402132a7d8d6479081ea4d4fd085204f5 Mon Sep 17 00:00:00 2001 From: Robert Onulak Date: Tue, 3 Apr 2018 08:53:35 -0700 Subject: [PATCH 04/20] Handles Mac paths in UnitySetupInstance. --- UnitySetup/UnitySetup.psm1 | 60 ++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index fc49176..165061c 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -35,8 +35,17 @@ class UnitySetupInstance { [string]$Path UnitySetupInstance([string]$path) { + + # Windows + if ((-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT")) { + $ivyPath = 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' + } + # Mac or Linux + else { + $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' + } - $ivyPath = [io.path]::Combine("$path", 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml'); + $ivyPath = [io.path]::Combine("$path", $ivyPath); if (!(Test-Path $ivyPath)) { throw "Path is not a Unity setup: $path"} [xml]$xmlDoc = Get-Content $ivyPath @@ -48,21 +57,40 @@ class UnitySetupInstance { $this.Version = $xmlDoc.'ivy-module'.info.unityVersion $this.Components = [UnitySetupComponent]::Setup - $componentTests = @{ - [UnitySetupComponent]::Documentation = , "$Path\Editor\Data\Documentation"; - [UnitySetupComponent]::StandardAssets = , "$Path\Editor\Standard Assets"; - [UnitySetupComponent]::Windows_IL2CPP = , "$Path\Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development_il2cpp"; - [UnitySetupComponent]::Metro = "$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_.NET_D3D", - "$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_D3D"; - [UnitySetupComponent]::UWP_IL2CPP = , "$Path\Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_IL2CPP_D3D"; - [UnitySetupComponent]::Android = , "$Path\Editor\Data\PlaybackEngines\AndroidPlayer"; - [UnitySetupComponent]::iOS = , "$Path\Editor\Data\PlaybackEngines\iOSSupport"; - [UnitySetupComponent]::AppleTV = , "$Path\Editor\Data\PlaybackEngines\AppleTVSupport"; - [UnitySetupComponent]::Facebook = , "$Path\Editor\Data\PlaybackEngines\Facebook"; - [UnitySetupComponent]::Linux = , "$Path\Editor\Data\PlaybackEngines\LinuxStandaloneSupport"; - [UnitySetupComponent]::Mac = , "$Path\Editor\Data\PlaybackEngines\MacStandaloneSupport"; - [UnitySetupComponent]::Vuforia = , "$Path\Editor\Data\PlaybackEngines\VuforiaSupport"; - [UnitySetupComponent]::WebGL = , "$Path\Editor\Data\PlaybackEngines\WebGLSupport"; + # Windows + if ((-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT")) { + $componentTests = @{ + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation"); + [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets"); + [UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development_il2cpp"); + [UnitySetupComponent]::Metro = [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_.NET_D3D"), + [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_D3D"); + [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_IL2CPP_D3D"); + [UnitySetupComponent]::Android = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\AndroidPlayer"); + [UnitySetupComponent]::iOS = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\iOSSupport"); + [UnitySetupComponent]::AppleTV = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\AppleTVSupport"); + [UnitySetupComponent]::Facebook = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\Facebook"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\LinuxStandaloneSupport"); + [UnitySetupComponent]::Mac = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MacStandaloneSupport"); + [UnitySetupComponent]::Vuforia = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\VuforiaSupport"); + [UnitySetupComponent]::WebGL = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\WebGLSupport"); + } + } + # Mac or Linux + else { + $componentTests = @{ + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation"); + [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Standard Assets"); + [UnitySetupComponent]::Android = , [io.path]::Combine("$Path", "PlaybackEngines/AndroidPlayer"); + [UnitySetupComponent]::iOS = , [io.path]::Combine("$Path", "PlaybackEngines/iOSSupport"); + [UnitySetupComponent]::AppleTV = , [io.path]::Combine("$Path", "PlaybackEngines/AppleTVSupport"); + [UnitySetupComponent]::Facebook = , [io.path]::Combine("$Path", "PlaybackEngines/Facebook"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$Path", "PlaybackEngines/LinuxStandaloneSupport"); + [UnitySetupComponent]::Windows = , [io.path]::Combine("$Path", "PlaybackEngines/WindowsStandaloneSupport"); + [UnitySetupComponent]::Mac = , [io.path]::Combine("$Path", "Unity.app/Contents/PlaybackEngines/MacStandaloneSupport"); + [UnitySetupComponent]::Vuforia = , [io.path]::Combine("$Path", "PlaybackEngines/VuforiaSupport"); + [UnitySetupComponent]::WebGL = , [io.path]::Combine("$Path", "PlaybackEngines/WebGLSupport"); + } } $componentTests.Keys | ForEach-Object { From 519d1a9bc02330756acdf0556f2a06ec39deac34 Mon Sep 17 00:00:00 2001 From: LVL Dev Date: Thu, 12 Apr 2018 10:54:46 -0700 Subject: [PATCH 05/20] Fixes Start-UnityEditor on Mac OS. --- UnitySetup/UnitySetup.psm1 | 122 +++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 54 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 165061c..24b5e44 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -2,7 +2,7 @@ # Licensed under the MIT License. Import-Module powershell-yaml -MinimumVersion '0.3' -ErrorAction Stop -[Flags()] +[Flags()] enum UnitySetupComponent { Setup = (1 -shl 0) Documentation = (1 -shl 1) @@ -18,6 +18,7 @@ enum UnitySetupComponent { Mac = (1 -shl 11) Vuforia = (1 -shl 12) WebGL = (1 -shl 13) + Windows = (1 -shl 14) All = (1 -shl 14) - 1 } @@ -33,7 +34,7 @@ class UnitySetupInstance { [UnityVersion]$Version [UnitySetupComponent]$Components [string]$Path - + UnitySetupInstance([string]$path) { # Windows @@ -44,14 +45,14 @@ class UnitySetupInstance { else { $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' } - + $ivyPath = [io.path]::Combine("$path", $ivyPath); if (!(Test-Path $ivyPath)) { throw "Path is not a Unity setup: $path"} [xml]$xmlDoc = Get-Content $ivyPath if ( !($xmlDoc.'ivy-module'.info.unityVersion)) { throw "Unity setup ivy is missing version: $ivyPath" - } + } $this.Path = $path $this.Version = $xmlDoc.'ivy-module'.info.unityVersion @@ -105,16 +106,16 @@ class UnitySetupInstance { } class UnityProjectInstance { - [UnityVersion]$Version + [UnityVersion]$Version [string]$Path - + UnityProjectInstance([string]$path) { $versionFile = [io.path]::Combine($path, "ProjectSettings\ProjectVersion.txt") if (!(Test-Path $versionFile)) { throw "Path is not a Unity project: $path"} $fileVersion = (Get-Content $versionFile -Raw | ConvertFrom-Yaml)['m_EditorVersion']; if (!$fileVersion) { throw "Project is missing a version in: $versionFile"} - + $this.Path = $path $this.Version = $fileVersion } @@ -138,13 +139,13 @@ class UnityVersion : System.IComparable { $parts = $version.Split('-') $parts[0] -match "(\d+)\.(\d+)\.(\d+)([fpb])(\d+)" | Out-Null - if ( $Matches.Count -ne 6 ) { throw "Invalid unity version: $version" } + if ( $Matches.Count -ne 6 ) { throw "Invalid unity version: $version" } $this.Major = [int]($Matches[1]); $this.Minor = [int]($Matches[2]); $this.Revision = [int]($Matches[3]); $this.Release = [char]($Matches[4]); $this.Build = [int]($Matches[5]); - + if ($parts.Length -gt 1) { $this.Suffix = $parts[1]; } @@ -153,20 +154,20 @@ class UnityVersion : System.IComparable { [int] CompareTo([object]$obj) { if ($null -eq $obj) { return 1 } if ($obj -isnot [UnityVersion]) { throw "Object is not a UnityVersion"} - + return [UnityVersion]::Compare($this, $obj) } static [int] Compare([UnityVersion]$a, [UnityVersion]$b) { if ($a.Major -lt $b.Major) { return -1 } if ($a.Major -gt $b.Major) { return 1 } - + if ($a.Minor -lt $b.Minor) { return -1 } if ($a.Minor -gt $b.Minor) { return 1 } - + if ($a.Revision -lt $b.Revision) { return -1 } if ($a.Revision -gt $b.Revision) { return 1 } - + if ($a.Release -lt $b.Release) { return -1 } if ($a.Release -gt $b.Release) { return 1 } @@ -182,7 +183,7 @@ class UnityVersion : System.IComparable { <# .Synopsis - Help to create UnitySetupComponent + Help to create UnitySetupComponent .PARAMETER Components What components would you like included? .EXAMPLE @@ -210,7 +211,7 @@ function ConvertTo-UnitySetupComponent { .EXAMPLE Find-UnitySetupInstaller -Version 2017.3.0f3 .EXAMPLE - Find-UnitySetupInstaller -Version 2017.3.0f3 -Components Setup,Documentation + Find-UnitySetupInstaller -Version 2017.3.0f3 -Components Setup,Documentation #> function Find-UnitySetupInstaller { [CmdletBinding()] @@ -263,8 +264,8 @@ function Find-UnitySetupInstaller { $patchPage = "https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)" $searchPages += $patchPage - $webResult = Invoke-WebRequest $patchPage -UseBasicParsing - $searchPages += $webResult.Links | Where-Object { + $webResult = Invoke-WebRequest $patchPage -UseBasicParsing + $searchPages += $webResult.Links | Where-Object { $_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" -and $Matches[1] -gt 1 } | ForEach-Object { "https://unity3d.com/unity/qa/patch-releases?version=$($Version.Major).$($Version.Minor)&page=$($Matches[1])" @@ -274,13 +275,13 @@ function Find-UnitySetupInstaller { foreach ($page in $searchPages) { $webResult = Invoke-WebRequest $page -UseBasicParsing - $prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object { - $_ -match "$($installerTemplates[[UnitySetupComponent]::Setup])$" + $prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object { + $_ -match "$($installerTemplates[[UnitySetupComponent]::Setup])$" } if ($null -ne $prototypeLink) { break } } - + if ($null -eq $prototypeLink) { throw "Could not find archives for Unity version $Version" } @@ -293,7 +294,7 @@ function Find-UnitySetupInstaller { else { $knownBaseUrls = $knownBaseUrls | Sort-Object -Property @{ Expression = {[math]::Abs(($_.CompareTo($linkComponents[0])))}; Ascending = $true} } - + $installerTemplates.Keys | Where-Object { $Components -band $_ } | ForEach-Object { $templates = $installerTemplates.Item($_); $result = $null @@ -383,7 +384,7 @@ function Install-UnitySetupInstance { $localDestinations += , "C:\Program Files\Unity-$($i.Version)" } - if ( Test-Path $destPath ) { + if ( Test-Path $destPath ) { $destItem = Get-Item $destPath if ( ($destItem.Length -eq $i.Length ) -and ($destItem.LastWriteTime -eq $i.LastModified) ) { Write-Verbose "Skipping download because it's already in the cache: $($i.DownloadUrl)" @@ -403,10 +404,10 @@ function Install-UnitySetupInstance { New-Item "$destDirectory" -ItemType Directory | Out-Null } } - + Start-BitsTransfer -Source $downloadSource -Destination $downloadDest } - + $spins = @('|', '/', '-', '\') for ($i = 0; $i -lt $localInstallers.Length; $i++) { $installer = $localInstallers[$i] @@ -421,7 +422,7 @@ function Install-UnitySetupInstance { if ($Verb) { $startProcessArgs['Verb'] = $Verb } - + $spinnerIndex = 0 $process = Start-Process @startProcessArgs while (!$process.HasExited) { @@ -433,7 +434,7 @@ function Install-UnitySetupInstance { Write-Host "`bFailed." Write-Error "Installing $installer failed with exit code: $($process.ExitCode)" } - else { + else { Write-Host "`bSucceeded." } } @@ -444,7 +445,7 @@ function Install-UnitySetupInstance { .Synopsis Uninstall Unity Setup Instances .DESCRIPTION - Uninstall the specified Unity Setup Instances + Uninstall the specified Unity Setup Instances .PARAMETER Instance What instances of UnitySetup should be uninstalled .EXAMPLE @@ -462,7 +463,7 @@ function Uninstall-UnitySetupInstance { $uninstaller = Get-ChildItem "$($setupInstance.Path)" -Filter 'Uninstall.exe' -Recurse | Select-Object -First 1 -ExpandProperty FullName - if ($null -eq $uninstaller) { + if ($null -eq $uninstaller) { Write-Error "Could not find Uninstaller.exe under $($setupInstance.Path)" continue } @@ -520,7 +521,7 @@ function Get-UnitySetupInstance { foreach ( $folder in $BasePath ) { $path = [io.path]::Combine("$folder", $ivyPath); - Get-ChildItem $path -Recurse -ErrorAction Ignore | + Get-ChildItem $path -Recurse -ErrorAction Ignore | ForEach-Object { [UnitySetupInstance]::new((Join-Path $_.Directory "..\..\..\..\..\" | Convert-Path)) } @@ -557,17 +558,17 @@ function Select-UnitySetupInstance { [parameter(Mandatory = $true, ValueFromPipeline = $true)] [UnitySetupInstance[]] $Instances ) - + process { - if ( $Version ) { + if ( $Version ) { $Instances = $Instances | Where-Object { [UnityVersion]::Compare($_.Version, $Version) -eq 0 } } if ( $Latest ) { - foreach ( $i in $Instances ) { - if ( $null -eq $latestInstance -or [UnityVersion]::Compare($i.Version, $latestInstance.Version) -gt 0) { + foreach ( $i in $Instances ) { + if ( $null -eq $latestInstance -or [UnityVersion]::Compare($i.Version, $latestInstance.Version) -gt 0) { $latestInstance = $i - } + } } } elseif ( $Instances.Count -gt 0 ) { $Instances } @@ -583,7 +584,7 @@ function Select-UnitySetupInstance { .DESCRIPTION Recursively discovers Unity projects and their Unity version .PARAMETER BasePath - Under what base pattern should we look for Unity projects? Defaults to '$PWD'. + Under what base pattern should we look for Unity projects? Defaults to '$PWD'. .EXAMPLE Get-UnityProjectInstance .EXAMPLE @@ -708,7 +709,7 @@ function Start-UnityEditor { [parameter(Mandatory = $false)] [switch]$PassThru ) - process { + process { switch -wildcard ( $PSCmdlet.ParameterSetName ) { 'Context' { $projectInstances = [UnityProjectInstance[]]@() @@ -725,17 +726,17 @@ function Start-UnityEditor { } } } - 'Projects*' { + 'Projects*' { $projectInstances = $Project $setupInstances = [UnitySetupInstance[]]@() } - 'Setups' { + 'Setups' { $projectInstances = [UnityProjectInstance[]]@() $setupInstances = $Setup } 'Latest' { $projectInstances = [UnityProjectInstance[]]@() - + $currentFolderProject = if (!$IgnoreProjectContext) { Get-UnityProjectInstance $PWD.Path } if ($null -ne $currentFolderProject) { $projectInstances += , $currentFolderProject @@ -778,8 +779,8 @@ function Start-UnityEditor { if ( $ImportPackage ) { $sharedArgs += "-importPackage", "$ImportPackage" } $instanceArgs = @() - foreach ( $p in $projectInstances ) { - + foreach ( $p in $projectInstances ) { + if ( $Latest ) { $setupInstance = Get-UnitySetupInstance | Select-UnitySetupInstance -Latest if ($setupInstance.Count -eq 0) { @@ -794,14 +795,14 @@ function Start-UnityEditor { continue } } - else { + else { $setupInstance = Get-UnitySetupInstance | Select-UnitySetupInstance -Version $p.Version if ($setupInstance.Count -eq 0) { Write-Error "Could not find Unity Editor for version $($p.Version)" continue } } - + $projectPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($($p.Path)) $instanceArgs += , ("-projectPath", $projectPath) $setupInstances += , $setupInstance @@ -809,14 +810,27 @@ function Start-UnityEditor { for ($i = 0; $i -lt $setupInstances.Length; $i++) { $setupInstance = $setupInstances[$i] - $editor = Get-ChildItem "$($setupInstance.Path)" -Filter 'Unity.exe' -Recurse | - Select-Object -First 1 -ExpandProperty FullName - if ([string]::IsNullOrEmpty($editor)) { - Write-Error "Could not find Unity.exe under setup instance path: $($setupInstance.Path)" - continue + # Windows + if ((-not $PSVersionTable.Platform) -or ($PSVersionTable.Platform -eq "Win32NT")) { + $editor = Get-ChildItem "$($setupInstance.Path)" -Filter 'Unity.exe' -Recurse | + Select-Object -First 1 -ExpandProperty FullName + + if ([string]::IsNullOrEmpty($editor)) { + Write-Error "Could not find Unity.exe under setup instance path: $($setupInstance.Path)" + continue + } + } + # Mac or Linux + else { + $editor = [io.path]::Combine("$($setupInstance.Path)", "Unity.app/Contents/MacOS/Unity") + + if ([string]::IsNullOrEmpty($editor)) { + Write-Error "Could not find Unity app under setup instance path: $($setupInstance.Path)" + continue + } } - + # clone the shared args list $unityArgs = $sharedArgs | ForEach-Object { $_ } if ( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] } @@ -855,16 +869,16 @@ function Start-UnityEditor { @{ 'Name' = 'gusi'; 'Value' = 'Get-UnitySetupInstance' }, @{ 'Name' = 'gupi'; 'Value' = 'Get-UnityProjectInstance' }, @{ 'Name' = 'susi'; 'Value' = 'Select-UnitySetupInstance' }, - @{ 'Name' = 'sue'; 'Value' = 'Start-UnityEditor' } -) | ForEach-Object { + @{ 'Name' = 'sue'; 'Value' = 'Start-UnityEditor' } +) | ForEach-Object { $alias = Get-Alias -Name $_.Name -ErrorAction 'SilentlyContinue' if( -not $alias ) { - Write-Verbose "Creating new alias $($_.Name) for $($_.Value)" - New-Alias @_ + Write-Verbose "Creating new alias $($_.Name) for $($_.Value)" + New-Alias @_ } elseif( $alias.ModuleName -eq 'UnitySetup' ) { - Write-Verbose "Setting alias $($_.Name) to $($_.Value)" + Write-Verbose "Setting alias $($_.Name) to $($_.Value)" Set-Alias @_ } else { From 95bbc2cbf5d53422f4c5dd4c228970b887c572e4 Mon Sep 17 00:00:00 2001 From: Robert Onulak Date: Thu, 12 Apr 2018 11:03:20 -0700 Subject: [PATCH 06/20] Fixes 'All' flag to be the next increment. --- UnitySetup/UnitySetup.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 24b5e44..8db3829 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -19,7 +19,7 @@ enum UnitySetupComponent { Vuforia = (1 -shl 12) WebGL = (1 -shl 13) Windows = (1 -shl 14) - All = (1 -shl 14) - 1 + All = (1 -shl 15) - 1 } class UnitySetupInstaller { @@ -884,4 +884,4 @@ function Start-UnityEditor { else { Write-Warning "Alias $($_.Name) already configured by $($alias.Source)" } -} \ No newline at end of file +} From 67df71179a6fa511bf4f15e9a59ec337d063b554 Mon Sep 17 00:00:00 2001 From: Robert Onulak Date: Fri, 13 Apr 2018 09:45:34 -0700 Subject: [PATCH 07/20] Better cross platform support and bails out when on a platform that's unsupported. Drops 'Setup' in favor of just stating 'Windows' on Windows platform. Updates README.md and -Examples to match with Setup changes. --- README.md | 67 +++++----- UnitySetup/UnitySetup.psm1 | 247 ++++++++++++++++++++++++------------- 2 files changed, 194 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index a8a7eb6..ed87dc9 100644 --- a/README.md +++ b/README.md @@ -28,19 +28,19 @@ Find all of your Unity installs: Get-UnitySetupInstance # Example output: -# Version Components Path -# ------- ---------- ---- -# 2017.1.2f1 Setup, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.1.2f1\ -# 2017.1.3f1 Setup, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.1.3f1\ -# 2017.2.1f1 Setup, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.2.1f1\ -# 2017.3.1f1 Setup, Metro, UWP_IL2CPP, Linux, Vuforia C:\Program Files\Unity-2017.3.1f1\ -# 2018.1.0b4 Setup, Metro, UWP_IL2CPP, Vuforia C:\Program Files\Unity-2018.1.0b4\ -# 2018.1.0b8 All C:\Program Files\Unity-2018.1.0b8\ -# 2017.1.0p5 Setup, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.0p5\ -# 2017.1.1f1 Setup, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.1f1\ -# 2017.1.1p3 Setup, StandardAssets, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.1p3\ -# 2017.2.0f3 Setup, Metro, UWP_IL2CPP, Vuforia C:\Program Files\Unity.2017.2.0f3\ -# 2017.3.0f3 Setup, Metro, UWP_IL2CPP, Mac, Vuforia C:\Program Files\Unity.2017.3.0f3\ +# Version Components Path +# ------- ---------- ---- +# 2017.1.2f1 Windows, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.1.2f1\ +# 2017.1.3f1 Windows, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.1.3f1\ +# 2017.2.1f1 Windows, Metro, UWP_IL2CPP C:\Program Files\Unity-2017.2.1f1\ +# 2017.3.1f1 Windows, Metro, UWP_IL2CPP, Linux, Vuforia C:\Program Files\Unity-2017.3.1f1\ +# 2018.1.0b4 Windows, Metro, UWP_IL2CPP, Vuforia C:\Program Files\Unity-2018.1.0b4\ +# 2018.1.0b8 All C:\Program Files\Unity-2018.1.0b8\ +# 2017.1.0p5 Windows, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.0p5\ +# 2017.1.1f1 Windows, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.1f1\ +# 2017.1.1p3 Windows, StandardAssets, Metro, UWP_IL2CPP C:\Program Files\Unity.2017.1.1p3\ +# 2017.2.0f3 Windows, Metro, UWP_IL2CPP, Vuforia C:\Program Files\Unity.2017.2.0f3\ +# 2017.3.0f3 Windows, Metro, UWP_IL2CPP, Mac, Vuforia C:\Program Files\Unity.2017.3.0f3\ ``` Select the Unity installs that you want: @@ -78,31 +78,32 @@ Find the installers for a particular version: Find-UnitySetupInstaller -Version '2017.3.0f3' | Format-Table # Example output: -# ComponentType Version Length LastModified DownloadUrl -# ------------- ------- ------ ------------ ----------- -# Setup 2017.3.0f3 553688024 2017-12-18 08:15:20 https://netstorage.unity3d.com/unity/... -# Documentation 2017.3.0f3 358911256 2017-12-18 08:18:37 https://netstorage.unity3d.com/unity/... -# StandardAssets 2017.3.0f3 189886032 2017-12-18 08:15:52 https://netstorage.unity3d.com/unity/... -# Metro 2017.3.0f3 172298008 2017-12-18 08:17:44 https://netstorage.unity3d.com/unity/... -# UWP_IL2CPP 2017.3.0f3 152933480 2017-12-18 08:17:55 https://netstorage.unity3d.com/unity/... -# Android 2017.3.0f3 194240888 2017-12-18 08:16:06 https://netstorage.unity3d.com/unity/... -# iOS 2017.3.0f3 802853872 2017-12-18 08:17:21 https://netstorage.unity3d.com/unity/... -# AppleTV 2017.3.0f3 273433528 2017-12-18 08:16:24 https://netstorage.unity3d.com/unity/... -# Facebook 2017.3.0f3 32131560 2017-12-18 08:16:27 https://netstorage.unity3d.com/unity/... -# Linux 2017.3.0f3 122271984 2017-12-18 08:17:30 https://netstorage.unity3d.com/unity/... -# Vuforia 2017.3.0f3 65677296 2017-12-18 08:18:00 https://netstorage.unity3d.com/unity/... -# WebGL 2017.3.0f3 134133288 2017-12-18 08:18:09 https://netstorage.unity3d.com/unity/... +# ComponentType Version Length LastModified DownloadUrl +# ------------- ------- ------ ------------ ----------- +# Windows 2017.3.0f3 553688024 12/18/2017 8:05:31 AM https://download.unity3d.com/download_unity/... +# Linux 2017.3.0f3 122271984 12/18/2017 8:06:53 AM https://download.unity3d.com/download_unity/... +# Mac 2017.3.0f3 28103888 12/18/2017 8:06:53 AM https://download.unity3d.com/download_unity/... +# Documentation 2017.3.0f3 358911256 12/18/2017 8:07:34 AM https://download.unity3d.com/download_unity/... +# StandardAssets 2017.3.0f3 189886032 12/18/2017 8:05:50 AM https://download.unity3d.com/download_unity/... +# Metro 2017.3.0f3 172298008 12/18/2017 8:07:04 AM https://download.unity3d.com/download_unity/... +# UWP_IL2CPP 2017.3.0f3 152933480 12/18/2017 8:07:10 AM https://download.unity3d.com/download_unity/... +# Android 2017.3.0f3 194240888 12/18/2017 8:05:58 AM https://download.unity3d.com/download_unity/... +# iOS 2017.3.0f3 802853872 12/18/2017 8:06:46 AM https://download.unity3d.com/download_unity/... +# AppleTV 2017.3.0f3 273433528 12/18/2017 8:06:09 AM https://download.unity3d.com/download_unity/... +# Facebook 2017.3.0f3 32131560 12/18/2017 8:06:12 AM https://download.unity3d.com/download_unity/... +# Vuforia 2017.3.0f3 65677296 12/18/2017 8:07:12 AM https://download.unity3d.com/download_unity/... +# WebGL 2017.3.0f3 134133288 12/18/2017 8:07:19 AM https://download.unity3d.com/download_unity/... ``` Limit what components you search for: ```powershell -Find-UnitySetupInstaller -Version 2017.3.0f3 -Components 'Setup','Documentation' | Format-Table +Find-UnitySetupInstaller -Version 2017.3.0f3 -Components 'Windows','Documentation' | Format-Table # Example output: -# ComponentType Version Length LastModified DownloadUrl -# ------------- ------- ------ ------------ ----------- -# Setup 2017.3.0f3 553688024 2017-12-18 08:15:20 https://netstorage.unity3d.com/unity/... -# Documentation 2017.3.0f3 358911256 2017-12-18 08:18:37 https://netstorage.unity3d.com/unity/... +# ComponentType Version Length LastModified DownloadUrl +# ------------- ------- ------ ------------ ----------- +# Windows 2017.3.0f3 553688024 12/18/2017 8:05:31 AM https://download.unity3d.com/download_unity/... +# Documentation 2017.3.0f3 358911256 12/18/2017 8:07:34 AM https://download.unity3d.com/download_unity/... ``` Install UnitySetup instances: @@ -129,7 +130,7 @@ Configuration Sample_xUnitySetupInstance_Install { xUnitySetupInstance Unity { Versions = '2017.3.1f1,2018.1.0b9' - Components = 'Setup', 'Mac', 'Linux', 'Metro', 'iOS' + Components = 'Windows', 'Mac', 'Linux', 'Metro', 'iOS' Ensure = 'Present' } } diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 200dc88..f9110b6 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -4,22 +4,28 @@ Import-Module powershell-yaml -MinimumVersion '0.3' -ErrorAction Stop [Flags()] enum UnitySetupComponent { - Setup = (1 -shl 0) - Documentation = (1 -shl 1) - StandardAssets = (1 -shl 2) - Windows_IL2CPP = (1 -shl 3) - Metro = (1 -shl 4) - UWP_IL2CPP = (1 -shl 5) - Android = (1 -shl 6) - iOS = (1 -shl 7) - AppleTV = (1 -shl 8) - Facebook = (1 -shl 9) - Linux = (1 -shl 10) - Mac = (1 -shl 11) + Windows = (1 -shl 0) + Linux = (1 -shl 1) + Mac = (1 -shl 2) + Documentation = (1 -shl 3) + StandardAssets = (1 -shl 4) + Windows_IL2CPP = (1 -shl 5) + Metro = (1 -shl 6) + UWP_IL2CPP = (1 -shl 7) + Android = (1 -shl 8) + iOS = (1 -shl 9) + AppleTV = (1 -shl 10) + Facebook = (1 -shl 11) Vuforia = (1 -shl 12) WebGL = (1 -shl 13) - Windows = (1 -shl 14) - All = (1 -shl 15) - 1 + All = (1 -shl 14) - 1 +} + +[Flags()] +enum OperatingSystem { + Windows + Linux + Mac } class UnitySetupInstaller { @@ -37,13 +43,11 @@ class UnitySetupInstance { UnitySetupInstance([string]$path) { - # Windows - if ((-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT")) { - $ivyPath = 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' - } - # Mac or Linux - else { - $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' + $currentOS = Get-OperatingSystem + $ivyPath = switch ($currentOS) { + ([OperatingSystem]::Windows) { 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' } + ([OperatingSystem]::Linux) { throw "UnitySetupInstance has not been implemented on the Linux platform. Contributions welcomed!"; } + ([OperatingSystem]::Mac) { 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' } } $ivyPath = [io.path]::Combine("$path", $ivyPath); @@ -56,44 +60,48 @@ class UnitySetupInstance { $this.Path = $path $this.Version = $xmlDoc.'ivy-module'.info.unityVersion - $this.Components = [UnitySetupComponent]::Setup - - # Windows - if ((-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT")) { - $componentTests = @{ - [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation"); - [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets"); - [UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win32_development_il2cpp"); - [UnitySetupComponent]::Metro = [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_.NET_D3D"), - [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_D3D"); - [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MetroSupport\Templates\UWP_IL2CPP_D3D"); - [UnitySetupComponent]::Android = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\AndroidPlayer"); - [UnitySetupComponent]::iOS = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\iOSSupport"); - [UnitySetupComponent]::AppleTV = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\AppleTVSupport"); - [UnitySetupComponent]::Facebook = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\Facebook"); - [UnitySetupComponent]::Linux = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\LinuxStandaloneSupport"); - [UnitySetupComponent]::Mac = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\MacStandaloneSupport"); - [UnitySetupComponent]::Vuforia = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\VuforiaSupport"); - [UnitySetupComponent]::WebGL = , [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines\WebGLSupport"); + + $playbackEnginePath = $null + $componentTests = switch ($currentOS) { + ([OperatingSystem]::Windows) { + $this.Components = [UnitySetupComponent]::Windows + $playbackEnginePath = [io.path]::Combine("$Path", "Editor\Data\PlaybackEngines"); + @{ + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Editor\Data\Documentation"); + [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets"); + [UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp"); + [UnitySetupComponent]::Metro = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"), + [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D"); + [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); + [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); + } } - } - # Mac or Linux - else { - $componentTests = @{ - [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation"); - [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Standard Assets"); - [UnitySetupComponent]::Android = , [io.path]::Combine("$Path", "PlaybackEngines/AndroidPlayer"); - [UnitySetupComponent]::iOS = , [io.path]::Combine("$Path", "PlaybackEngines/iOSSupport"); - [UnitySetupComponent]::AppleTV = , [io.path]::Combine("$Path", "PlaybackEngines/AppleTVSupport"); - [UnitySetupComponent]::Facebook = , [io.path]::Combine("$Path", "PlaybackEngines/Facebook"); - [UnitySetupComponent]::Linux = , [io.path]::Combine("$Path", "PlaybackEngines/LinuxStandaloneSupport"); - [UnitySetupComponent]::Windows = , [io.path]::Combine("$Path", "PlaybackEngines/WindowsStandaloneSupport"); - [UnitySetupComponent]::Mac = , [io.path]::Combine("$Path", "Unity.app/Contents/PlaybackEngines/MacStandaloneSupport"); - [UnitySetupComponent]::Vuforia = , [io.path]::Combine("$Path", "PlaybackEngines/VuforiaSupport"); - [UnitySetupComponent]::WebGL = , [io.path]::Combine("$Path", "PlaybackEngines/WebGLSupport"); + ([OperatingSystem]::Linux) { + $this.Components = [UnitySetupComponent]::Linux + + throw "UnitySetupInstance has not been implemented on the Linux platform. Contributions welcomed!"; + } + ([OperatingSystem]::Mac) { + $this.Components = [UnitySetupComponent]::Mac + $playbackEnginePath = [io.path]::Combine("$Path", "PlaybackEngines"); + @{ + [UnitySetupComponent]::Documentation = , [io.path]::Combine("$Path", "Documentation"); + [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Standard Assets"); + [UnitySetupComponent]::Windows = , [io.path]::Combine("$playbackEnginePath", "WindowsStandaloneSupport"); + [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); + } } } + # Common playback engines: + $componentTests[[UnitySetupComponent]::Android] = , [io.path]::Combine("$playbackEnginePath", "AndroidPlayer"); + $componentTests[[UnitySetupComponent]::iOS] = , [io.path]::Combine("$playbackEnginePath", "iOSSupport"); + $componentTests[[UnitySetupComponent]::AppleTV] = , [io.path]::Combine("$playbackEnginePath", "AppleTVSupport"); + $componentTests[[UnitySetupComponent]::Facebook] = , [io.path]::Combine("$playbackEnginePath", "Facebook"); + $componentTests[[UnitySetupComponent]::Vuforia] = , [io.path]::Combine("$playbackEnginePath", "VuforiaSupport"); + $componentTests[[UnitySetupComponent]::WebGL] = , [io.path]::Combine("$playbackEnginePath", "WebGLSupport"); + $componentTests.Keys | ForEach-Object { foreach ( $test in $componentTests[$_] ) { if ( Test-Path -PathType Container -Path $test ) { @@ -181,13 +189,51 @@ class UnityVersion : System.IComparable { } } +<# +.Synopsis + Easy way to determine the current operating system platform being executed on. +.DESCRIPTION + Determine which operating system that's executing the script for things like path variants. +.EXAMPLE + $OS = Get-OperatingSystem +.EXAMPLE + # Loosely typed. + switch (Get-OperatingSystem) { + Windows { echo "On Windows" } + Linux { echo "On Linux" } + Mac { echo "On Mac" } + } +.EXAMPLE + # Strongly typed. + switch (Get-OperatingSystem) { + ([OperatingSystem]::Windows) { echo "On Windows" } + ([OperatingSystem]::Linux) { echo "On Linux" } + ([OperatingSystem]::Mac) { echo "On Mac" } + } +.EXAMPLE + if (Get-OperatingSystem == [OperatingSystem]::Linux) { + echo "On Linux" + } +#> +function Get-OperatingSystem { + if ((-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT")) { + return [OperatingSystem]::Windows + } + elseif ($global:PSVersionTable.OS.Contains("Linux")) { + return [OperatingSystem]::Linux + } + elseif ($global:PSVersionTable.OS.Contains("Darwin")) { + return [OperatingSystem]::Mac + } +} + <# .Synopsis Help to create UnitySetupComponent .PARAMETER Components What components would you like included? .EXAMPLE - ConvertTo-UnitySetupComponent Setup,Metro + ConvertTo-UnitySetupComponent Windows,Metro #> function ConvertTo-UnitySetupComponent { [CmdletBinding()] @@ -211,7 +257,7 @@ function ConvertTo-UnitySetupComponent { .EXAMPLE Find-UnitySetupInstaller -Version 2017.3.0f3 .EXAMPLE - Find-UnitySetupInstaller -Version 2017.3.0f3 -Components Setup,Documentation + Find-UnitySetupInstaller -Version 2017.3.0f3 -Components Windows,Documentation #> function Find-UnitySetupInstaller { [CmdletBinding()] @@ -231,7 +277,6 @@ function Find-UnitySetupInstaller { ) $installerTemplates = @{ - [UnitySetupComponent]::Setup = , "Windows64EditorInstaller/UnitySetup64-$Version.exe"; [UnitySetupComponent]::Documentation = , "WindowsDocumentationInstaller/UnityDocumentationSetup-$Version.exe"; [UnitySetupComponent]::StandardAssets = , "WindowsStandardAssetsInstaller/UnityStandardAssetsSetup-$Version.exe"; [UnitySetupComponent]::Metro = , "TargetSupportInstaller/UnitySetup-Metro-Support-for-Editor-$Version.exe"; @@ -242,12 +287,32 @@ function Find-UnitySetupInstaller { [UnitySetupComponent]::Facebook = , "TargetSupportInstaller/UnitySetup-Facebook-Games-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Linux = , "TargetSupportInstaller/UnitySetup-Linux-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Mac = "TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-$Version.exe", - "TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe"; + "TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Vuforia = , "TargetSupportInstaller/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::WebGL = , "TargetSupportInstaller/UnitySetup-WebGL-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Windows_IL2CPP = , "TargetSupportInstaller/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.exe"; } + $currentOS = Get-OperatingSystem + switch ($currentOS) { + ([OperatingSystem]::Windows) { + $setupComponent = [UnitySetupComponent]::Windows + $installerTemplates[$setupComponent] = , "Windows64EditorInstaller/UnitySetup64-$Version.exe"; + } + ([OperatingSystem]::Linux) { + $setupComponent = [UnitySetupComponent]::Linux + # TODO: $installerTemplates[$setupComponent] = , "???/UnitySetup64-$Version.exe"; + + throw "Find-UnitySetupInstaller has not been implemented on the Linux platform. Contributions welcomed!"; + } + ([OperatingSystem]::Mac) { + $setupComponent = [UnitySetupComponent]::Mac + # TODO: $installerTemplates[$setupComponent] = , "???/UnitySetup64-$Version.exe"; + + throw "Find-UnitySetupInstaller has not been implemented on the Mac platform. Contributions welcomed!"; + } + } + # By default Tls12 protocol is not enabled, but is what backs Unity's website, so enable it $secProtocol = [System.Net.ServicePointManager]::SecurityProtocol if ( ($secProtocol -band [System.Net.SecurityProtocolType]::Tls12) -eq 0 ) { @@ -274,7 +339,7 @@ function Find-UnitySetupInstaller { foreach ($page in $searchPages) { $webResult = Invoke-WebRequest $page -UseBasicParsing $prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object { - $_ -match "$($installerTemplates[[UnitySetupComponent]::Setup])$" + $_ -match "$($installerTemplates[$setupComponent])$" } if ($null -ne $prototypeLink) { break } @@ -497,19 +562,22 @@ function Get-UnitySetupInstance { [string[]] $BasePath ) - # Windows - if ((-not $PSVersionTable.Platform) -or ($PSVersionTable.Platform -eq "Win32NT")) { - if (-not $BasePath) { - $BasePath = @('C:\Program Files*\Unity*', 'C:\Program Files\Unity\Hub\Editor\*') + switch (Get-OperatingSystem) { + ([OperatingSystem]::Windows) { + if (-not $BasePath) { + $BasePath = @('C:\Program Files*\Unity*', 'C:\Program Files\Unity\Hub\Editor\*') + } + $ivyPath = 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' } - $ivyPath = 'Editor\Data\UnityExtensions\Unity\Networking\ivy.xml' - } - # Mac or Linux - else { - if (-not $BasePath) { - $BasePath = @('/Applications/Unity*') + ([OperatingSystem]::Linux) { + throw "Get-UnitySetupInstance has not been implemented on the Linux platform. Contributions welcomed!"; + } + ([OperatingSystem]::Mac) { + if (-not $BasePath) { + $BasePath = @('/Applications/Unity*') + } + $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' } - $ivyPath = 'Unity.app/Contents/UnityExtensions/Unity/Networking/ivy.xml' } foreach ( $folder in $BasePath ) { @@ -802,26 +870,31 @@ function Start-UnityEditor { $setupInstances += , $setupInstance } + $currentOS = Get-OperatingSystem + for ($i = 0; $i -lt $setupInstances.Length; $i++) { $setupInstance = $setupInstances[$i] - # Windows - if ((-not $PSVersionTable.Platform) -or ($PSVersionTable.Platform -eq "Win32NT")) { - $editor = Get-ChildItem "$($setupInstance.Path)" -Filter 'Unity.exe' -Recurse | - Select-Object -First 1 -ExpandProperty FullName - - if ([string]::IsNullOrEmpty($editor)) { - Write-Error "Could not find Unity.exe under setup instance path: $($setupInstance.Path)" - continue + switch ($currentOS) { + ([OperatingSystem]::Windows) { + $editor = Get-ChildItem "$($setupInstance.Path)" -Filter 'Unity.exe' -Recurse | + Select-Object -First 1 -ExpandProperty FullName + + if ([string]::IsNullOrEmpty($editor)) { + Write-Error "Could not find Unity.exe under setup instance path: $($setupInstance.Path)" + continue + } } - } - # Mac or Linux - else { - $editor = [io.path]::Combine("$($setupInstance.Path)", "Unity.app/Contents/MacOS/Unity") - - if ([string]::IsNullOrEmpty($editor)) { - Write-Error "Could not find Unity app under setup instance path: $($setupInstance.Path)" - continue + ([OperatingSystem]::Linux) { + throw "Start-UnityEditor has not been implemented on the Linux platform. Contributions welcomed!"; + } + ([OperatingSystem]::Mac) { + $editor = [io.path]::Combine("$($setupInstance.Path)", "Unity.app/Contents/MacOS/Unity") + + if ([string]::IsNullOrEmpty($editor)) { + Write-Error "Could not find Unity app under setup instance path: $($setupInstance.Path)" + continue + } } } From 8fa0a3d020f1106cbdb130cc549697713e0ab8b8 Mon Sep 17 00:00:00 2001 From: Robert Onulak Date: Fri, 13 Apr 2018 09:56:46 -0700 Subject: [PATCH 08/20] Adds .OUTPUTS to the Get-OperatingSystem documentation. --- UnitySetup/UnitySetup.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index f9110b6..6ee4e24 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -194,6 +194,8 @@ class UnityVersion : System.IComparable { Easy way to determine the current operating system platform being executed on. .DESCRIPTION Determine which operating system that's executing the script for things like path variants. +.OUTPUTS + Get-OperatingSystem returns a [OperatingSystem] enumeration based off the Powershell platform being run on. .EXAMPLE $OS = Get-OperatingSystem .EXAMPLE From 9e88eda3d764a1de122c55d9386399cb2de5ca54 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Mon, 16 Apr 2018 10:50:28 -0700 Subject: [PATCH 09/20] Version bump for incoming changes --- UnitySetup/UnitySetup.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psd1 b/UnitySetup/UnitySetup.psd1 index d5b8271..e037934 100644 --- a/UnitySetup/UnitySetup.psd1 +++ b/UnitySetup/UnitySetup.psd1 @@ -14,7 +14,7 @@ RootModule = 'UnitySetup' # Version number of this module. - ModuleVersion = '3.0' + ModuleVersion = '4.0' # Supported PSEditions # CompatiblePSEditions = @() From 7cf05df51edefa867471054d57e4af22491e10f7 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Fri, 27 Apr 2018 12:45:17 -0700 Subject: [PATCH 10/20] Added AcceptAPIUpdate parameter. --- UnitySetup/UnitySetup.psm1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 6ee4e24..1483cbf 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -709,6 +709,8 @@ function Get-UnityProjectInstance { The log file for the Unity Editor to write to. .PARAMETER BuildTarget The platform build target for the Unity Editor to start in. +.PARAMETER AcceptAPIUpdate + Accept the API Updater automatically. Implies BatchMode unless explicitly specified by the user. .PARAMETER BatchMode Should the Unity Editor start in batch mode? .PARAMETER Quit @@ -765,6 +767,8 @@ function Start-UnityEditor { [ValidateSet('StandaloneOSX', 'StandaloneWindows', 'iOS', 'Android', 'StandaloneLinux', 'StandaloneWindows64', 'WebGL', 'WSAPlayer', 'StandaloneLinux64', 'StandaloneLinuxUniversal', 'Tizen', 'PSP2', 'PS4', 'XBoxOne', 'N3DS', 'WiiU', 'tvOS', 'Switch')] [string]$BuildTarget, [parameter(Mandatory = $false)] + [switch]$AcceptAPIUpdate, + [parameter(Mandatory = $false)] [switch]$BatchMode, [parameter(Mandatory = $false)] [switch]$Quit, @@ -832,6 +836,11 @@ function Start-UnityEditor { } $sharedArgs = @() + if ( $AcceptAPIUpdate ) { + $sharedArgs += '-accept-apiupdate' + if( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true } + } + if ( $CreateProject ) { $sharedArgs += "-createProject", $CreateProject } if ( $ExecuteMethod ) { $sharedArgs += "-executeMethod", $ExecuteMethod } if ( $OutputPath ) { $sharedArgs += "-buildOutput", $OutputPath } From cffd9254490e8a96578bcc0b864bb188f8f9ac54 Mon Sep 17 00:00:00 2001 From: Steven Liss Date: Fri, 27 Apr 2018 14:07:42 -0700 Subject: [PATCH 11/20] Made 'Project' parameter positional on Start cmd --- UnitySetup/UnitySetup.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 1483cbf..1c4f69c 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -733,9 +733,9 @@ function Get-UnityProjectInstance { function Start-UnityEditor { [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "Context")] param( - [parameter(Mandatory = $false, ValueFromPipeline = $true, ParameterSetName = 'Projects')] - [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'ProjectsLatest')] - [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'ProjectsVersion')] + [parameter(Mandatory = $false, ValueFromPipeline = $true, ParameterSetName = 'Projects', Position = 0)] + [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'ProjectsLatest', Position = 0)] + [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'ProjectsVersion', Position = 0)] [ValidateNotNullOrEmpty()] [UnityProjectInstance[]] $Project, [parameter(Mandatory = $false, ValueFromPipeline = $true, ParameterSetName = 'Setups')] From 5d9b4fc34a924877492e0d11f6ba567712795bb1 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Fri, 27 Apr 2018 16:26:47 -0700 Subject: [PATCH 12/20] Wait in the Start-Process call. --- UnitySetup/UnitySetup.psm1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 1c4f69c..94bdc06 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -71,7 +71,7 @@ class UnitySetupInstance { [UnitySetupComponent]::StandardAssets = , [io.path]::Combine("$Path", "Editor\Standard Assets"); [UnitySetupComponent]::Windows_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "windowsstandalonesupport\Variations\win32_development_il2cpp"); [UnitySetupComponent]::Metro = [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_.NET_D3D"), - [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D"); + [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_D3D"); [UnitySetupComponent]::UWP_IL2CPP = , [io.path]::Combine("$playbackEnginePath", "MetroSupport\Templates\UWP_IL2CPP_D3D"); [UnitySetupComponent]::Linux = , [io.path]::Combine("$playbackEnginePath", "LinuxStandaloneSupport"); [UnitySetupComponent]::Mac = , [io.path]::Combine("$playbackEnginePath", "MacStandaloneSupport"); @@ -289,7 +289,7 @@ function Find-UnitySetupInstaller { [UnitySetupComponent]::Facebook = , "TargetSupportInstaller/UnitySetup-Facebook-Games-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Linux = , "TargetSupportInstaller/UnitySetup-Linux-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Mac = "TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-$Version.exe", - "TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe"; + "TargetSupportInstaller/UnitySetup-Mac-Mono-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Vuforia = , "TargetSupportInstaller/UnitySetup-Vuforia-AR-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::WebGL = , "TargetSupportInstaller/UnitySetup-WebGL-Support-for-Editor-$Version.exe"; [UnitySetupComponent]::Windows_IL2CPP = , "TargetSupportInstaller/UnitySetup-Windows-IL2CPP-Support-for-Editor-$Version.exe"; @@ -480,6 +480,7 @@ function Install-UnitySetupInstance { 'FilePath' = $installer; 'ArgumentList' = @("/S", "/D=$destination"); 'PassThru' = $true; + 'Wait' = $true; } if ($Verb) { @@ -488,9 +489,7 @@ function Install-UnitySetupInstance { Write-Verbose "$(Get-Date): Installing $installer to $destination." $process = Start-Process @startProcessArgs - if( $process ) { - $process.WaitForExit() - + if ( $process ) { if ( $process.ExitCode -ne 0) { Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)" } @@ -838,7 +837,7 @@ function Start-UnityEditor { $sharedArgs = @() if ( $AcceptAPIUpdate ) { $sharedArgs += '-accept-apiupdate' - if( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true } + if ( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true } } if ( $CreateProject ) { $sharedArgs += "-createProject", $CreateProject } @@ -921,6 +920,8 @@ function Start-UnityEditor { 'RedirectStandardError' = New-TemporaryFile; } + if ($Wait) { $setProcessArgs['Wait'] = $true } + Write-Verbose "Redirecting standard output to $($setProcessArgs['RedirectStandardOutput'])" Write-Verbose "Redirecting standard error to $($setProcessArgs['RedirectStandardError'])" @@ -934,13 +935,12 @@ function Start-UnityEditor { $process = Start-Process @setProcessArgs if ( $Wait ) { - $process.WaitForExit(); if ( $process.ExitCode -ne 0 ) { if ( $LogFile -and (Test-Path $LogFile -Type Leaf) ) { Get-Content $LogFile | ForEach-Object { Write-Information -MessageData $_ -Tags 'Logs' } } - Write-Error "Unity quit with non-zero exit code" + Write-Error "Unity quit with non-zero exit code: $($process.ExitCode)" } } From 1db828e21dcf513a3c9e6115944a9a9f92eeef9e Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Fri, 27 Apr 2018 12:11:11 -0700 Subject: [PATCH 13/20] Add license query and management support --- .../xUnityLicense/xUnityLicense.psm1 | 101 ++++++++++++++++++ .../xUnityLicense/xUnityLicense.schema.mof | 11 ++ UnitySetup/Examples/Sample_xUnity.ps1 | 43 ++++++++ .../Examples/Sample_xUnitySetupInstance.ps1 | 28 ----- .../Sample_xUnitySetupInstance_Install.ps1 | 16 --- .../Sample_xUnitySetupInstance_Uninstall.ps1 | 15 --- UnitySetup/Examples/Sample_xUnity_Install.ps1 | 30 ++++++ .../Examples/Sample_xUnity_Uninstall.ps1 | 29 +++++ UnitySetup/UnitySetup.psd1 | 3 +- UnitySetup/UnitySetup.psm1 | 80 +++++++++++++- 10 files changed, 291 insertions(+), 65 deletions(-) create mode 100644 UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 create mode 100644 UnitySetup/DSCResources/xUnityLicense/xUnityLicense.schema.mof create mode 100644 UnitySetup/Examples/Sample_xUnity.ps1 delete mode 100644 UnitySetup/Examples/Sample_xUnitySetupInstance.ps1 delete mode 100644 UnitySetup/Examples/Sample_xUnitySetupInstance_Install.ps1 delete mode 100644 UnitySetup/Examples/Sample_xUnitySetupInstance_Uninstall.ps1 create mode 100644 UnitySetup/Examples/Sample_xUnity_Install.ps1 create mode 100644 UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 diff --git a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 new file mode 100644 index 0000000..f082a66 --- /dev/null +++ b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 @@ -0,0 +1,101 @@ +function Get-TargetResource { + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [System.Management.Automation.PSCredential] + $Credential, + + [System.Management.Automation.PSCredential] + $Serial, + + [System.String] + $UnityVersion, + + [System.String] + $Name + ) + + @{ 'Licenses' = (Get-UnityLicense) } +} + + +function Set-TargetResource { + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $Credential, + + [ValidateSet("Present", "Absent")] + [System.String] + $Ensure = 'Present', + + [parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $Serial, + + [System.String] + $UnityVersion, + + [parameter(Mandatory = $true)] + [System.String] + $Name + ) + + if ( Test-TargetResource @PSBoundParameters ) { return } + + $unityArgs = @{ + 'Credential' = $Credential + 'Wait' = $true + } + + if ( $UnityVersion ) { $unityArgs['Version'] = $UnityVersion } + if ( $Ensure -eq 'Present' ) { $unityArgs['Serial'] = $Serial.Password } + else { $unityArgs['ReturnLicense'] = $true } + + Start-UnityEditor @unityArgs -Verbose +} + + +function Test-TargetResource { + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [System.Management.Automation.PSCredential] + $Credential, + + [ValidateSet("Present", "Absent")] + [System.String] + $Ensure = 'Present', + + [parameter(Mandatory = $true)] + [System.Management.Automation.PSCredential] + $Serial, + + [System.String] + $UnityVersion, + + [parameter(Mandatory = $true)] + [System.String] + $Name + ) + + foreach ( $license in (Get-UnityLicense -Serial $Serial.Password) ) { + Write-Verbose "Found license: $license" + + $currentSerial = [System.Net.NetworkCredential]::new($null, $license.Serial).Password + $passedSerial = $Serial.GetNetworkCredential().Password + if ( $currentSerial -ne $passedSerial ) { continue } + + return $Ensure -eq 'Present' + } + + return $Ensure -eq 'Absent' +} + + +Export-ModuleMember -Function *-TargetResource + diff --git a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.schema.mof b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.schema.mof new file mode 100644 index 0000000..3394e96 --- /dev/null +++ b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.schema.mof @@ -0,0 +1,11 @@ + +[ClassVersion("1.0.0.0"), FriendlyName("xUnityLicense")] +class xUnityLicense : OMI_BaseResource +{ + [Key] string Name; + [Required, EmbeddedInstance("MSFT_Credential")] String Credential; + [Required, EmbeddedInstance("MSFT_Credential")] String Serial; + [Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; + [Write] string UnityVersion; +}; + diff --git a/UnitySetup/Examples/Sample_xUnity.ps1 b/UnitySetup/Examples/Sample_xUnity.ps1 new file mode 100644 index 0000000..460dff3 --- /dev/null +++ b/UnitySetup/Examples/Sample_xUnity.ps1 @@ -0,0 +1,43 @@ +<# + Create a custom configuration by passing in necessary values +#> +Configuration Sample_xUnitySetupInstance { + param + ( + [System.String] + $Versions = '2017.4.2f2' + + [ValidateSet('Present', 'Absent')] + [System.String] + $Ensure = 'Present', + + [System.String[]] + $Components = @('Windows', 'Mac', 'Linux', 'Metro', 'iOS', 'Android'), + + [PSCredential] + $UnityCredential, + + [PSCredential] + $UnitySerial + ) + + Import-DscResource -ModuleName UnitySetup + + Node 'localhost' { + + xUnitySetupInstance Unity { + Versions = $Versions + Components = $Components + Ensure = $Ensure + DependsOn = if( $Ensure -eq 'Absent' ) { '[xUnityLicense]UnityLicense' } + } + + xUnityLicense UnityLicense { + Name = 'UL01' + Credential = $UnityCredential + Serial = $UnitySerial + Ensure = $Ensure + DependsOn = if( $Ensure -eq 'Present' ) { '[xUnitySetupInstance]Unity' } + } + } +} \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnitySetupInstance.ps1 b/UnitySetup/Examples/Sample_xUnitySetupInstance.ps1 deleted file mode 100644 index 7280942..0000000 --- a/UnitySetup/Examples/Sample_xUnitySetupInstance.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -<# - Create a custom configuration by passing in necessary values -#> -Configuration Sample_xUnitySetupInstance { - param - ( - [System.String] - $Versions = '2017.3.0f3,2018.1.0b9', - - [ValidateSet('Present', 'Absent')] - [System.String] - $Ensure = 'Present', - - [System.String[]] - $Components = @('Setup', 'Linux', 'Metro', 'Mac', 'iOS') - ) - - Import-DscResource -ModuleName UnitySetup - - Node 'localhost' { - - xUnitySetupInstance Unity { - Versions = $Versions - Components = $Components - Ensure = $Ensure - } - } -} \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnitySetupInstance_Install.ps1 b/UnitySetup/Examples/Sample_xUnitySetupInstance_Install.ps1 deleted file mode 100644 index 7763dc3..0000000 --- a/UnitySetup/Examples/Sample_xUnitySetupInstance_Install.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -<# - Install multiple versions of Unity and several components -#> -Configuration Sample_xUnitySetupInstance_Install { - - Import-DscResource -ModuleName UnitySetup - - Node 'localhost' { - - xUnitySetupInstance Unity { - Versions = '2017.3.1f1,2018.1.0b9' - Components = 'Setup', 'Mac', 'Linux', 'Metro', 'iOS' - Ensure = 'Present' - } - } -} \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnitySetupInstance_Uninstall.ps1 b/UnitySetup/Examples/Sample_xUnitySetupInstance_Uninstall.ps1 deleted file mode 100644 index c5f0764..0000000 --- a/UnitySetup/Examples/Sample_xUnitySetupInstance_Uninstall.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -<# - Uninstall multiple versions of Unity -#> -Configuration Sample_xUnitySetupInstance_Install { - - Import-DscResource -ModuleName UnitySetup - - Node 'localhost' { - - xUnitySetupInstance Unity { - Versions = '2017.3.1f1,2018.1.0b9' - Ensure = 'Absent' - } - } -} \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnity_Install.ps1 b/UnitySetup/Examples/Sample_xUnity_Install.ps1 new file mode 100644 index 0000000..9bfdff5 --- /dev/null +++ b/UnitySetup/Examples/Sample_xUnity_Install.ps1 @@ -0,0 +1,30 @@ +<# + Install multiple versions of Unity and several components +#> +Configuration Sample_xUnitySetupInstance_Install { + + param( + [PSCredential]$UnityCredential, + [PSCredential]$UnitySerial + ) + + Import-DscResource -ModuleName UnitySetup + + Node 'localhost' { + + xUnitySetupInstance Unity { + Versions = '2017.4.2f2' + Components = 'Windows', 'Mac', 'Linux', 'Metro', 'iOS', 'Android' + Ensure = 'Present' + } + + xUnityLicense UnityLicense { + Name = 'UL01' + Credential = $UnityCredential + Serial = $UnitySerial + Ensure = 'Present' + UnityVersion = '2017.4.2f2' + DependsOn = '[xUnitySetupInstance]Unity' + } + } +} \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 b/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 new file mode 100644 index 0000000..cb08487 --- /dev/null +++ b/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 @@ -0,0 +1,29 @@ +<# + Uninstall multiple versions of Unity +#> +Configuration Sample_xUnitySetupInstance_Install { + + param( + [PSCredential]$UnityCredential, + [PSCredential]$UnitySerial + ) + + Import-DscResource -ModuleName UnitySetup + + Node 'localhost' { + + xUnitySetupInstance Unity { + Versions = '2017.4.2f2' + Ensure = 'Absent' + DependsOn = '[xUnityLicense]UnityLicense' + } + + xUnityLicense UnityLicense { + Name = 'UL01' + Credential = $UnityCredential + Serial = $UnitySerial + Ensure = 'Absent' + UnityVersion = '2017.4.2f2' + } + } +} \ No newline at end of file diff --git a/UnitySetup/UnitySetup.psd1 b/UnitySetup/UnitySetup.psd1 index e037934..ad94d75 100644 --- a/UnitySetup/UnitySetup.psd1 +++ b/UnitySetup/UnitySetup.psd1 @@ -82,7 +82,8 @@ 'Select-UnitySetupInstance', 'Uninstall-UnitySetupInstance', 'Start-UnityEditor', - 'ConvertTo-UnitySetupComponent' + 'ConvertTo-UnitySetupComponent', + 'Get-UnityLicense' ) # 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. diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 94bdc06..4db4e4d 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -710,6 +710,12 @@ function Get-UnityProjectInstance { The platform build target for the Unity Editor to start in. .PARAMETER AcceptAPIUpdate Accept the API Updater automatically. Implies BatchMode unless explicitly specified by the user. +.PARAMETER Credential + What user name and password should be used by Unity for activation? +.PARAMETER Serial + What serial should be used by Unity for activation? Implies BatchMode and Quit if they're not supplied by the User. +.PARAMETER ReturnLicense + Unity should return the current license it's been activated with. Implies Quit if not supplied by the User. .PARAMETER BatchMode Should the Unity Editor start in batch mode? .PARAMETER Quit @@ -768,6 +774,14 @@ function Start-UnityEditor { [parameter(Mandatory = $false)] [switch]$AcceptAPIUpdate, [parameter(Mandatory = $false)] + [pscredential]$Credential, + [parameter(Mandatory = $false)] + [securestring]$Serial, + [parameter(Mandatory = $false)] + [switch]$ReturnLicense, + [parameter(Mandatory = $false)] + [switch]$ForceFree, + [parameter(Mandatory = $false)] [switch]$BatchMode, [parameter(Mandatory = $false)] [switch]$Quit, @@ -835,11 +849,20 @@ function Start-UnityEditor { } $sharedArgs = @() + if ( $ReturnLicense ) { + if ( -not $PSBoundParameters.ContainsKey('BatchMode') ) { $BatchMode = $true } + if ( -not $PSBoundParameters.ContainsKey('Quit') ) { $Quit = $true } + + $sharedArgs += '-returnLicense' + } + if ( $Serial ) { + if ( -not $PSBoundParameters.ContainsKey('BatchMode') ) { $BatchMode = $true } + if ( -not $PSBoundParameters.ContainsKey('Quit') ) { $Quit = $true } + } if ( $AcceptAPIUpdate ) { $sharedArgs += '-accept-apiupdate' if ( -not $PSBoundParameters.ContainsKey('BatchMode')) { $BatchMode = $true } } - if ( $CreateProject ) { $sharedArgs += "-createProject", $CreateProject } if ( $ExecuteMethod ) { $sharedArgs += "-executeMethod", $ExecuteMethod } if ( $OutputPath ) { $sharedArgs += "-buildOutput", $OutputPath } @@ -849,6 +872,8 @@ function Start-UnityEditor { if ( $Quit ) { $sharedArgs += "-quit" } if ( $ExportPackage ) { $sharedArgs += "-exportPackage", "$ExportPackage" } if ( $ImportPackage ) { $sharedArgs += "-importPackage", "$ImportPackage" } + if ( $Credential ) { $sharedArgs += '-username', $Credential.UserName } + if ( $ForceFree) { $sharedArgs += '-force-free' } $instanceArgs = @() foreach ( $p in $projectInstances ) { @@ -925,18 +950,27 @@ function Start-UnityEditor { Write-Verbose "Redirecting standard output to $($setProcessArgs['RedirectStandardOutput'])" Write-Verbose "Redirecting standard error to $($setProcessArgs['RedirectStandardError'])" - if ($unityArgs -and $unityArgs.Length -gt 0) { - $setProcessArgs['ArgumentList'] = $unityArgs - } + $actionString = "$editor $unityArgs" + if( $Credential ) { $actionString += " -password (hidden)"} + if( $Serial ) { $actionString += " -serial (hidden)"} - if (-not $PSCmdlet.ShouldProcess("$editor $unityArgs", "Start-Process")) { + if (-not $PSCmdlet.ShouldProcess($actionString, "Start-Process")) { continue } + # Defered till after potential display by ShouldProcess + if ( $Credential ) { $unityArgs += '-password', $Credential.GetNetworkCredential().Password } + if ( $Serial ) { $unityArgs += '-serial', [System.Net.NetworkCredential]::new($null, $Serial).Password } + + if ($unityArgs -and $unityArgs.Length -gt 0) { + $setProcessArgs['ArgumentList'] = $unityArgs + } + $process = Start-Process @setProcessArgs if ( $Wait ) { if ( $process.ExitCode -ne 0 ) { if ( $LogFile -and (Test-Path $LogFile -Type Leaf) ) { + Write-Verbose "Writing $LogFile to Information stream Tagged as 'Logs'" Get-Content $LogFile | ForEach-Object { Write-Information -MessageData $_ -Tags 'Logs' } } @@ -949,6 +983,42 @@ function Start-UnityEditor { } } +function ConvertTo-DateTime { + param([string] $Text) + + if( -not $text -or $text.Length -eq 0 ) { [DateTime]::MaxValue } + else { [DateTime]$Text } +} + +function Get-UnityLicense +{ + [CmdletBinding()] + param([SecureString]$Serial, [UnityVersion]$UnityVersion) + + $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" + foreach ( $licenseFile in $licenseFiles ) { + Write-Verbose "Discovered License File at $licenseFile" + $doc = [xml](Get-Content "$licenseFile") + $devBytes = [System.Convert]::FromBase64String($doc.root.License.DeveloperData.Value) + + # The first four bytes look like a count so skip that to pull out the serial string + $licenseSerial = [String]::new($devBytes[4..($devBytes.Length - 1)]) + if( $Serial -and [System.Net.NetworkCredential]::new($null, $Serial).Password -ne $licenseSerial ) { continue; } + + $license = $doc.root.License + [PSCustomObject]@{ + 'LicenseVersion' = $license.LicenseVersion.Value + 'Serial' = ConvertTo-SecureString $licenseSerial -AsPlainText -Force + 'UnityVersion' = [UnityVersion]$license.ClientProvidedVersion.Value + 'DisplaySerial' = $license.SerialMasked.Value + 'ActivationDate' = ConvertTo-DateTime $license.InitialActivationDate.Value + 'StartDate' = ConvertTo-DateTime $license.StartDate.Value + 'StopDate' = ConvertTo-DateTime $license.StopDate.Value + 'UpdateDate' = ConvertTo-DateTime $license.UpdateDate.Value + } + } +} + @( @{ 'Name' = 'gusi'; 'Value' = 'Get-UnitySetupInstance' }, @{ 'Name' = 'gupi'; 'Value' = 'Get-UnityProjectInstance' }, From b1c66b43d6ffe7f65dd686c26771138088c49460 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Tue, 1 May 2018 15:07:14 -0700 Subject: [PATCH 14/20] License DSC Fixes and Sample improvement --- .../DSCResources/xUnityLicense/xUnityLicense.psm1 | 6 ++++++ UnitySetup/Examples/Sample_xUnity.ps1 | 11 ++++++----- UnitySetup/Examples/Sample_xUnity_Install.ps1 | 2 +- UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 index f082a66..2c456dd 100644 --- a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 +++ b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 @@ -3,15 +3,19 @@ [OutputType([System.Collections.Hashtable])] param ( + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Credential, + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Serial, + [parameter(Mandatory = $false)] [System.String] $UnityVersion, + [parameter(Mandatory = $true)] [System.String] $Name ) @@ -64,6 +68,7 @@ function Test-TargetResource { [OutputType([System.Boolean])] param ( + [parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $Credential, @@ -75,6 +80,7 @@ function Test-TargetResource { [System.Management.Automation.PSCredential] $Serial, + [parameter(Mandatory = $false)] [System.String] $UnityVersion, diff --git a/UnitySetup/Examples/Sample_xUnity.ps1 b/UnitySetup/Examples/Sample_xUnity.ps1 index 460dff3..68c4dce 100644 --- a/UnitySetup/Examples/Sample_xUnity.ps1 +++ b/UnitySetup/Examples/Sample_xUnity.ps1 @@ -1,11 +1,11 @@ <# Create a custom configuration by passing in necessary values #> -Configuration Sample_xUnitySetupInstance { +Configuration Sample_xUnity { param ( [System.String] - $Versions = '2017.4.2f2' + $Version = '2017.4.2f2', [ValidateSet('Present', 'Absent')] [System.String] @@ -26,10 +26,10 @@ Configuration Sample_xUnitySetupInstance { Node 'localhost' { xUnitySetupInstance Unity { - Versions = $Versions + Versions = $Version Components = $Components Ensure = $Ensure - DependsOn = if( $Ensure -eq 'Absent' ) { '[xUnityLicense]UnityLicense' } + DependsOn = if( $Ensure -eq 'Absent' ) { '[xUnityLicense]UnityLicense' } else { $null } } xUnityLicense UnityLicense { @@ -37,7 +37,8 @@ Configuration Sample_xUnitySetupInstance { Credential = $UnityCredential Serial = $UnitySerial Ensure = $Ensure - DependsOn = if( $Ensure -eq 'Present' ) { '[xUnitySetupInstance]Unity' } + UnityVersion = $Version + DependsOn = if( $Ensure -eq 'Present' ) { '[xUnitySetupInstance]Unity' } else { $null } } } } \ No newline at end of file diff --git a/UnitySetup/Examples/Sample_xUnity_Install.ps1 b/UnitySetup/Examples/Sample_xUnity_Install.ps1 index 9bfdff5..866f004 100644 --- a/UnitySetup/Examples/Sample_xUnity_Install.ps1 +++ b/UnitySetup/Examples/Sample_xUnity_Install.ps1 @@ -1,7 +1,7 @@ <# Install multiple versions of Unity and several components #> -Configuration Sample_xUnitySetupInstance_Install { +Configuration Sample_xUnity_Install { param( [PSCredential]$UnityCredential, diff --git a/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 b/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 index cb08487..95d153f 100644 --- a/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 +++ b/UnitySetup/Examples/Sample_xUnity_Uninstall.ps1 @@ -1,7 +1,7 @@ <# Uninstall multiple versions of Unity #> -Configuration Sample_xUnitySetupInstance_Install { +Configuration Sample_xUnity_Install { param( [PSCredential]$UnityCredential, From 8bcafa3d1eff64d4e24708b88b932419469b0184 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Tue, 1 May 2018 16:04:35 -0700 Subject: [PATCH 15/20] Fix for missing folders --- UnitySetup/UnitySetup.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 4db4e4d..2035afa 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -995,7 +995,7 @@ function Get-UnityLicense [CmdletBinding()] param([SecureString]$Serial, [UnityVersion]$UnityVersion) - $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" + $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" -ErrorAction 'SilentlyContinue' foreach ( $licenseFile in $licenseFiles ) { Write-Verbose "Discovered License File at $licenseFile" $doc = [xml](Get-Content "$licenseFile") From 2d28258b5bdc066e90329c38ea9d7b0ed8ec8dec Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Thu, 10 May 2018 14:51:28 -0700 Subject: [PATCH 16/20] Added copyrights --- UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 | 4 +++- .../DSCResources/xUnitySetupInstance/xUnitySetupInstance.psm1 | 2 ++ build.ps1 | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 index 2c456dd..f06cac5 100644 --- a/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 +++ b/UnitySetup/DSCResources/xUnityLicense/xUnityLicense.psm1 @@ -1,4 +1,6 @@ -function Get-TargetResource { +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +function Get-TargetResource { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param diff --git a/UnitySetup/DSCResources/xUnitySetupInstance/xUnitySetupInstance.psm1 b/UnitySetup/DSCResources/xUnitySetupInstance/xUnitySetupInstance.psm1 index f23990f..f6fb73c 100644 --- a/UnitySetup/DSCResources/xUnitySetupInstance/xUnitySetupInstance.psm1 +++ b/UnitySetup/DSCResources/xUnitySetupInstance/xUnitySetupInstance.psm1 @@ -1,4 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. <# .Synopsis Returns the status of Unity installs and the set of their overlapping components. diff --git a/build.ps1 b/build.ps1 index bc3f140..e6c2ab1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + param([int]$Revision = 0, [string]$Suffix = '') Import-Module 'PowerShellGet' -Force From 63fb834acc21a0b207def4622d5fdd8db6868bd5 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Thu, 10 May 2018 16:03:35 -0700 Subject: [PATCH 17/20] Added security contact info --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed87dc9..8f076c1 100644 --- a/README.md +++ b/README.md @@ -149,4 +149,8 @@ This project welcomes contributions and suggestions. Most contributions require When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +# Reporting Security Issues + +Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). \ No newline at end of file From d239d56a344cb48e69bbb31c28072978fe73a0b8 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Wed, 16 May 2018 13:09:45 -0700 Subject: [PATCH 18/20] Add license documentation --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed87dc9..19df9ac 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,28 @@ Find-UnitySetupInstaller -Version '2017.3.0f3' | Install-UnitySetupInstance Install-UnitySetupInstance -Installers (Find-UnitySetupInstaller -Version '2017.3.0f3') ``` +Manage Unity licenses. +```powershell +# Get any active licenses +Get-UnityLicense + +# Example Output: +# LicenseVersion : 6.x +# Serial : System.Security.SecureString +# UnityVersion : 2017.4.2f2 +# DisplaySerial : AB-CDEF-GHIJ-KLMN-OPQR-XXXX +# ActivationDate : 2017-07-13 16:32:16 +# StartDate : 2017-07-12 00:00:00 +# StopDate : 2019-01-01 00:00:00 +# UpdateDate : 2018-05-11 23:47:10 + +# Activate a license +Start-UnityEditor -Credential -Serial -Wait + +# Return license +Start-UnityEditor -Credential -ReturnLicense -Wait +``` + ### DSC UnitySetup includes the xUnitySetupInstance DSC Resource. An example configuration might look like: @@ -123,16 +145,29 @@ UnitySetup includes the xUnitySetupInstance DSC Resource. An example configurati Install multiple versions of Unity and several components #> Configuration Sample_xUnitySetupInstance_Install { + param( + [PSCredential]$UnityCredential, + [PSCredential]$UnitySerial + ) Import-DscResource -ModuleName UnitySetup Node 'localhost' { xUnitySetupInstance Unity { - Versions = '2017.3.1f1,2018.1.0b9' + Versions = '2017.4.2f2,2018.1.0f2' Components = 'Windows', 'Mac', 'Linux', 'Metro', 'iOS' Ensure = 'Present' } + + xUnityLicense UnityLicense { + Name = 'UL01' + Credential = $UnityCredential + Serial = $UnitySerial + Ensure = 'Present' + UnityVersion = '2017.4.2f2' + DependsOn = '[xUnitySetupInstance]Unity' + } } } ``` From b9eaad7685aed49781cc55fa26e5335e9351e6cd Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Wed, 16 May 2018 13:27:54 -0700 Subject: [PATCH 19/20] Document Get-UnityLicense --- UnitySetup/UnitySetup.psm1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 2035afa..5f859e7 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -990,10 +990,18 @@ function ConvertTo-DateTime { else { [DateTime]$Text } } +<# +.Synopsis + Get the active Unity licenses for the machine. +.PARAMETER Serial + Filter licenses to the specified serial +.EXAMPLE + Get-UnityLicense +#> function Get-UnityLicense { [CmdletBinding()] - param([SecureString]$Serial, [UnityVersion]$UnityVersion) + param([SecureString]$Serial) $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" -ErrorAction 'SilentlyContinue' foreach ( $licenseFile in $licenseFiles ) { From 68c0ee8effe2e96d519c0517a3e2990870ec6b28 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Mon, 21 May 2018 15:16:52 -0700 Subject: [PATCH 20/20] Suppress inappropraitely applied rule --- UnitySetup/UnitySetup.psm1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index 5f859e7..39002e9 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -482,10 +482,6 @@ function Install-UnitySetupInstance { 'PassThru' = $true; 'Wait' = $true; } - - if ($Verb) { - $startProcessArgs['Verb'] = $Verb - } Write-Verbose "$(Get-Date): Installing $installer to $destination." $process = Start-Process @startProcessArgs @@ -1001,6 +997,7 @@ function ConvertTo-DateTime { function Get-UnityLicense { [CmdletBinding()] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification="Used to convert discovered plaintext serials into secure strings.")] param([SecureString]$Serial) $licenseFiles = Get-ChildItem "C:\ProgramData\Unity\Unity_*.ulf" -ErrorAction 'SilentlyContinue'