microsoft / unitysetup.powershell

Powershell module for interfacing with Unity installs and projects.
MIT License
179 stars 48 forks source link

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

Open kobechenyang opened 5 years ago

kobechenyang commented 5 years ago

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 ?

jwittner commented 5 years ago

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?

kobechenyang commented 5 years ago

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```
jwittner commented 5 years ago

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.

kobechenyang commented 5 years ago

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?

jwittner commented 5 years ago

Reopening under new title to capture these doc issues.