unitysetup.powershell icon indicating copy to clipboard operation
unitysetup.powershell copied to clipboard

Select-UnitySetupInstance : Readme indicates a non-existant 'Project' parameter and description of 'Path' parameter doesn't match functionality.

Open kobechenyang opened this issue 6 years ago • 5 comments

When calling Start-UnityEditor -Project .\build-machine-setup I am getting this error:

Start-UnityEditor : Cannot process argument transformation on parameter 'Project'. 
Cannot convert value ".\build-machine-setup" to type "UnityProjectInstance[]". Error:     
"Cannot convert value ".\build-machine-setup" to type "UnityProjectInstance". Error:      
"Exception calling "Load" with "1" argument(s): "(Line: 1, Col: 1, Idx: 0) - (Line: 1, 
Col: 2, Idx: 1): While scanning for the next token, find character that cannot start any  
token."""
At line:1 char:28
+ Start-UnityEditor -Project .\build-machine-setup
+                            ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-UnityEditor], ParameterBindingArgu  
   mentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Start-UnityEditor  

Any idea what is happening ?

kobechenyang avatar Sep 27 '19 06:09 kobechenyang

Interesting. Looking at the constructor for UnityProjectInstance,, my guess is that it's failing to parse either ProjectSettings\ProjectVersion.txt or ProjectSettings\ProjectSettings.asset.

Does your Unity project have it's Asset Serialization Mode set as 'Force Text'? Text assets are expected by UnitySetup.

If that isn't the issue, would you mind taking a snip of your folder hierarchy and dropping your copies of the above two files into the issue?

jwittner avatar Sep 27 '19 17:09 jwittner

Thanks for your answer ! But it didn't fix the problem. My project is empty unity project. But it was created with different version. I don't know if that matters. Also I notice when I call Select-UnitySetupInstance -Project '.\build-machine-setup' Also getting an error

At line:1 char:27
+ Select-UnitySetupInstance -Project 'C:\Users\kobec\build-machine-setu ...
+                           ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Select-UnitySetupInstance], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Select-UnitySetupInstance```

kobechenyang avatar Sep 27 '19 23:09 kobechenyang

Select-UnitySetupInstance doesn't have a Project parameter so that error makes sense. That cmdlet is for filtering the results of Get-UnitySetupInstance which finds installs of Unity on your machine. Highly recommend reading the README and running help <command>, e.g. help Select-UnitySetupInstance to learn more about the API.

Get-UnityProjectInstance -Recurse will find unity projects recursively under a folder. If .\build-machine-setup is the root of a Unity project it should find it, detect the version, and print out the details. Start-UnityEditor -Project <path to project> will either launch the right version of Unity or complain that it can't find it (it uses the *-UnitySetupInstance cmdlets for this).

Can you post your ProjectSettings\ProjectVersion.txt and ProjectSettings\ProjectSettings.asset? These are the only files relied upon by UnitySetup and if it's a clean Unity project shouldn't have any private information in it. With those I should be able to reproduce your issue and give further guidance.

jwittner avatar Sep 28 '19 00:09 jwittner

You are right, Get-UnitySetupInstance doesn't have a project parameter. After I did Get-UnityProjectInstance -Recurse I was able to do a Start-UnityEditor -Project <path to project>. This Get-UnitySetupInstance | Select-UnitySetupInstance -Project '.\MyUnityProject' command inside README file is outdated then. Thanks. Can you modified README file?

kobechenyang avatar Sep 28 '19 03:09 kobechenyang

Reopening under new title to capture these doc issues.

jwittner avatar Sep 30 '19 19:09 jwittner