microsoft / unitysetup.powershell Goto Github PK
View Code? Open in Web Editor NEWPowershell module for interfacing with Unity installs and projects.
License: MIT License
Powershell module for interfacing with Unity installs and projects.
License: MIT License
PowerShell Core is now cross-platform. We should investigate supporting the *nix world, including Mac.
Add necessary activation/return flags to Start-UnityEditor
.
Create DSC resource xUnitySetupLicense
.
It's more likely that we have many projects we want to start than it is to have many installs for one project. It makes this easy and possible:
Get-UnityProjectInstance -Recurse | Start-UnityEditor
in Install-UnitySetupInstance
the line
Start-BitsTransfer -Source $downloadSource -Destination $downloadDest
fails if it's executed from a Visual Studio Team Services build agent with as the VSTS Agent runs as a service.
2018-08-03T17:31:03.2273217Z DEBUG: 472+ >>>> Start-BitsTransfer -Source $downloadSource -Destination $downloadDest
2018-08-03T17:31:03.7159554Z Start-BitsTransfer : The operation being requested was not performed because the user has not logged on to the
2018-08-03T17:31:03.7159834Z network. The specified service does not exist. (Exception from HRESULT: 0x800704DD)
2018-08-03T17:31:03.7160174Z At C:\Program Files\WindowsPowerShell\Modules\UnitySetup\4.0.97\UnitySetup.psm1:472 char:13
Either credentials need to be supplied to the call (and piped through as params) or it should use webclient to download the installer
(New-Object System.Net.WebClient).DownloadFile([string]$downloadSource, [string]$downloadDest)
I'm testing this E2E now.
I'm tempted to drop the BuildTarget ValidateSet
so we don't have this dependency that requires this code to change on the Unity whims.
Docs to latest cmd line support: https://docs.unity3d.com/2018.1/Documentation/Manual/CommandLineArguments.html
Right now it returns the Editor subfolder within the install folder, that makes installing using the detected paths pretty annoying and isn't probably what people expect.
Right now it downloads them one at a time then installs all. It should download them all asynchronously, when the main installer for the platform is done it should install that, then it should install components as they finish downloading.
This matches more closely to existing patterns and fits in nicely with the upcoming xUnitySetupLicense
DSC resource from #83
Attempting to download 2017.1.1p1 with this command: Find-UnitySetupInstaller -Version '2017.1.2f1' | Install-UnitySetupInstance
.
Installer gets to UnityExampleProjectSetup-2017.1.1p1.exe
and installs fine. Noticed after this install the Unity install directory is overwritten with the example scene. Unity.exe is now deleted and thus the installation is now borked.
Find-UnitySetupInstaller -Version '2017.3.1p1' -Components Setup | Install-UnitySetupInstance
)result: Script attempts to update its progress spinner, ends up printing lots of output:
Installing C:\Users\forrest\.unitysetup\Installers\Unity-2017.3.1p1\UnitySetup64-2017.3.1p1.exe to C:\Program Files\UnitInstalling C:\Users\forrest\.unitysetup\Installers\Unity-2017.3.1p1\UnitySetup64-2017.3.1p1.exe to C:\Program Files\UnitInstalling C:\Users\forrest\.unitysetup\Installers\Unity-2017.3.1p1\UnitySetup64-2017.3.1p1.exe to C:\Program Files\UnitInstalling C:\Users\forrest\.unitysetup\Installers\Unity-2017.3.1p1\UnitySetup64-2017.3.1p1.exe to C:\Program Files\UnitInstalling C:\Users\forrest\.unitysetup\Installers\Unity-2017.3.1p1\UnitySetup64-2017.3.1p1.exe to C:\Program Files\UnitInstalling C:\User...
expected: Progress spinner outputs in place or output is more sparing/organized.
If the version is not installed, the function should perform the -MissingVersionAction, which can be any of Confirm, ConfirmVersion, Install, Fallback, Error
MissingVersionAction, defaults to Confirm.
Example 'Confirm' output:
Would you like to?
[A] Install the missing version or [B] launch with latest version or [C] Specify a version or [D] Cancel.
C
What version?
>
Using ConfirmVersion
skips the initial prompt, and asks just what version you'd like to use. Install
auto installs without asking. Latest
launches with the latest installed version. Error
results in the exception we see now.
Note that defaulting to Confirm
means a major version bump to account for the change in behavior. We could default to Error
and make this a minor version bump. We could export a variable to control the default - $UnitySetupMissingVersionActionPreference
so that people can change their default.
Removing it from that list should make publishing verify the module exists on the gallery and install it when installing our module.
My Example:
C:\WINDOWS\system32> $installers = Find-UnitySetupInstaller -Version 2017.2.0p3 -Components Setup -Verbose
VERBOSE: GET https://unity3d.com/unity/qa/patch-releases?version=2017.2 with 0-byte payload
VERBOSE: received 73560-byte response of content type text/html; charset=utf-8
VERBOSE: GET https://unity3d.com/unity/qa/patch-releases?version=2017.2 with 0-byte payload
VERBOSE: received 73560-byte response of content type text/html; charset=utf-8
Could not find archives for Unity version 2017.2.0p3
At C:\Users\jowitt\Documents\WindowsPowerShell\Modules\UnitySetup\3.0.80\UnitySetup.psm1:257 char:9
+ throw "Could not find archives for Unity version $Version"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Could not find ...sion 2017.2.0p3:String) [], RuntimeException
+ FullyQualifiedErrorId : Could not find archives for Unity version 2017.2.0p3
Looks like the regex against the page urls is failing now.
UnityGet would be available on the PSGallery and would provide Unity installations through the standard PackageManagement module.
Checking for leaked weakptr:
Found no leaked weakptrs.
##utp:{"type":"MemoryLeaks","allocatedMemory":25398947,"memoryLabels":[{"Default":3148},{"NewDelete":6397012},{"Manager":224},{"Texture":480},{"TextureCache":-480},{"FMOD":640},{"Physics":1},{"Serialization":29792},{"Terrain":224},{"String":39656},{"DynamicArray":30073},{"HashMap":18846208},{"Curl":1528},{"PoolAlloc":-224},{"Sprites":8},{"CloudService":-2360},{"VR":1704},{"EditorGui":280},{"EditorUtility":35680},{"AssetImporter":32},{"RestService":72},{"EditorGi":5785},{"UnityConnect":9376},{"Collab":720},{"Upm":-632}]}
expected: No additional output.
Running Invoke-ScriptAnalyzer UnitySetup\UnitySetup.psm1
results in
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseShouldProcessForStateChangingF Warning UnitySetup 492 Function ’Start-UnityEditor’ has verb that could change
unctions .psm1 system state. Therefore, the function has to support
'ShouldProcess'.
PSAvoidUsingWriteHost Warning UnitySetup 303 File 'UnitySetup.psm1' uses Write-Host. Avoid using
.psm1 Write-Host because it might not work in all hosts, does not
work when there is no host, and (prior to PS 5.0) cannot be
suppressed, captured, or redirected. Instead, use
Write-Output, Write-Verbose, or Write-Information.
PSAvoidUsingWriteHost Warning UnitySetup 309 File 'UnitySetup.psm1' uses Write-Host. Avoid using
.psm1 Write-Host because it might not work in all hosts, does not
work when there is no host, and (prior to PS 5.0) cannot be
suppressed, captured, or redirected. Instead, use
Write-Output, Write-Verbose, or Write-Information.
PSAvoidUsingWriteHost Warning UnitySetup 314 File 'UnitySetup.psm1' uses Write-Host. Avoid using
.psm1 Write-Host because it might not work in all hosts, does not
work when there is no host, and (prior to PS 5.0) cannot be
suppressed, captured, or redirected. Instead, use
Write-Output, Write-Verbose, or Write-Information.
Looks like the installer name changed and we need support for the new location.
Find-UnitySetupInstaller -Version 2018.2.1f1 -Components Metro
Not sure if this is possible, but it would make installing the right components necessary for a project simpler. Right now to encompass everything we have install everything.
They refer to the unavailable UnitySetupComponentType
type.
Install-Module UnitySetup -Scope CurrentUser
to install UnitySetup
.Running the one example Find-UnitySetupInstaller -Version '2017.3.0f3' | Format-Table
outputs:
WARNING: Unable to find installer for the WebGL component.
WARNING: Unable to find installer for the Metro component.
WARNING: Unable to find installer for the StandardAssets component.
WARNING: Unable to find installer for the Windows component.
WARNING: Unable to find installer for the UWP_IL2CPP component.
WARNING: Unable to find installer for the AppleTV component.
WARNING: Unable to find installer for the Vuforia component.
WARNING: Unable to find installer for the Windows_IL2CPP component.
WARNING: Unable to find installer for the Documentation component.
WARNING: Unable to find installer for the iOS component.
WARNING: Unable to find installer for the Mac component.
WARNING: Unable to find installer for the Android component.
WARNING: Unable to find installer for the Linux component.
WARNING: Unable to find installer for the Facebook component.
I'm able to run other commands like Get-UnitySetupInstance
.
Installing the module in PowerShell on the same machine works just fine.
Our build process launches the Unity editor using the Start-UnityEditor. We often end up with errors such as "Start-UnityEditor : Unity quit with non-zero exit code: 1." when our build fails.
It can be time-consuming to search a large Unity log for errors. It would be awesome if Start-UnityEditor could understand Unity's log file and pull out error messages and summarized them in its error output.
Start-UnityEditor -BatchMode -Wait -Quit -Project <project>
fails because the exit code is not set, it's not non-zero, we're running into an issue with Start-Process.
Functions
Select-UnitySetupInstance Start-UnityEditor Get-UnitySetupInstance Find-UnitySetupInstaller Install-UnitySetupInstance Get-UnityProjectInstance ConvertFrom-Yaml ConvertTo-Yaml
Suppressing the analyzer warning is a clear indication of that.
Change to ConvertTo-UnitySetupComponent.
PS C:\Users\bryce> Find-UnitySetupInstaller -Version 2017.3.0p4 -Components Setup
Could not find archives for Unity version 2017.3.0p4
At C:\Users\bryce\OneDrive\Documents\WindowsPowerShell\Modules\UnitySetup\2.1.43\UnitySetup.psm1:204 char:9
+ throw "Could not find archives for Unity version $Version"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Could not find ...sion 2017.3.0p4:String) [], RuntimeException
+ FullyQualifiedErrorId : Could not find archives for Unity version 2017.3.0p4
It seems to fail on any "p" releases. I got the version numbers from the Patch Releases page. Other release types seem to be working correctly.
This would make it easy to wrap all the installs with one UAC prompt when performing locally.
Add a -Verb param to Install-UnitySetupInstance that forwards to the start-process call so that as an admin I can launch Unity as an admin.
When you try to start a unity editor for a project that has an uninstalled unity version, you get an error that doesn't make it clear that you must install the corresponding unity version.
Input:
Start-UnityEditor -Project C:\Users\defreed\Source\Repos\Test\
Output:
Start-UnityEditor : Could not find Unity.exe under setup instance path:
At line:1 char:1
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-UnityEditor
Investigate ramifications of aliases.
Proposed:
gusi => Get-UnitySetupInstance
gupi => Get-UnityProjectInstance
sue => Start-UnityEditor
Would enable this
gupi -r | sue
Now that we can detect installs, find installers, and install unity, we can create a DSC resource for ensuring versions of Unity are installed.
ImportPackage in Start-UnityEditor should support relative paths so that the user does not have to resolve their path
If you pull an existing project without a project version, unitysetup should start the project in the most recent unity version on your pc
repro: Start-UnityEditor -Version "2017.22.2f3"
Right now Find-UnitySetupInstaller
requires you to specify a version. It'd be great if I could specify -Latest
or neither to find all versions.
Version
being specified.I think I'm going to write-warning
and then you can control the warning action for the cmdlet.
I should be able to enter Start-UnityEditor "path to unity project" and it should start as if I 'cd' there and use Start-UnityEditor without any args.
Running a command like Find-UnitySetupInstaller -Version '2017.1.2f1' | Install-UnitySetupInstance
and Find-UnitySetupInstaller -Version '2017.1.1p1' | Install-UnitySetupInstance
at the same time was causing issues with both versions being unable to install properly.
Both Unity install folders end up looking like Unity projects. Which was quite weird.
Suggested to allow for downloading all the setup files in parallel and / or up front. Lock installation to only a single one at a time.
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingConvertToSecureStringWi Error UnitySetup 1015 File 'UnitySetup.psm1' uses ConvertTo-SecureString with
thPlainText .psm1 plaintext. This will expose secure information. Encrypted
standard strings should be used instead.
Add a new parameter AcceptAPIUpdate
and pipe it to Unity.
Installed the 2018 beta via the Unity Hub, did not appear when running Get-UnitySetupInstance.
The builds act like they succeeded, but they have not. Looks like AppVeyor updated it's host machines and now some imports don't work.
I'll try to apply the -AllowClobber flag to see if the imports fix the issue.
When applying the auto-formatting in VS Code, there are a ton of changes. Make a PR that updates the formatting so that auto-formatting doesn't change the document so much.
in script do:
Set-PSDebug -Trace 2
Call Install-UnitySetupInstance
Bug - the line $process = Start-Process @startProcessArgs
has issues when Trace set to 2.
Cannot convert value to type System.String.
At C:\Program Files\WindowsPowerShell\Modules\UnitySetup\4.0.97\UnitySetup.psm1:487 char:13
$process = Start-Process @startProcessArgs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
perhaps consider using:
Start-Process @startPRocessARgs -OutVariable $result | Out-Null
I'm trying to install the Mac component for Unity 2017.1.2p3. Finding the Mac installer returns nothing, including no error.
PS C:\Users\bryce> Find-UnitySetupInstaller -Version 2017.1.2p3 -Components Mac
PS C:\Users\bryce> Find-UnitySetupInstaller -Version 2017.1.2p3 -Components Setup
ComponentType : Setup
Version : 2017.1.2p3
Length : 541722008
LastModified : 11/21/2017 5:27:22 AM
DownloadUrl : https://beta.unity3d.com/download/249a06fbaf10/Windows64EditorInstaller/UnitySetup64-2017.1.2p3.exe
I downloaded the component through the Download Assistant and sniffed the component url: http://download.unity3d.com/download_unity/249a06fbaf10/TargetSupportInstaller/UnitySetup-Mac-Support-for-Editor-2017.1.2p3.exe
e.g. Get-UnitySetupInstance | Select-UnitySetupInstance -Version 2017.3.1f1 | Uninstall-UnitySetupIns tance
)Set/Remove environment variables, eg. {key:"UNITY_2017.4.2f2", value: ""}.
This would make them discoverable in online build systems and leveraged appropriately.
You see this error:
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "UnityInstance".
At C:\Users\jowitt\Documents\WindowsPowerShell\Modules\UnitySetup\1.4.29\UnitySetup.psm1:260 char:9
+ $Instance = Get-UnitySetupInstance | Select-UnitySetupInstan ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : ConvertToFinalInvalidCastException
Could not find Unity Editor for version
At C:\Users\jowitt\Documents\WindowsPowerShell\Modules\UnitySetup\1.4.29\UnitySetup.psm1:270 char:9
+ throw "Could not find Unity Editor for version $version"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Could not find Unity Editor for version :String) [], RuntimeException
+ FullyQualifiedErrorId : Could not find Unity Editor for version
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.