From 05d2f6bbb24e73ff8e78ee70c1e47e2c9a6a7fe1 Mon Sep 17 00:00:00 2001 From: Tim Gerken Date: Fri, 29 Mar 2019 17:13:37 +0000 Subject: [PATCH 1/2] Expose productName in UnityProjectInstance --- UnitySetup/UnitySetup.psm1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index c65758d..353526b 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -122,6 +122,7 @@ class UnitySetupInstance { class UnityProjectInstance { [UnityVersion]$Version [string]$Path + [string]$ProductName UnityProjectInstance([string]$path) { $versionFile = [io.path]::Combine($path, "ProjectSettings\ProjectVersion.txt") @@ -130,8 +131,15 @@ class UnityProjectInstance { $fileVersion = (Get-Content $versionFile -Raw | ConvertFrom-Yaml)['m_EditorVersion']; if (!$fileVersion) { throw "Project is missing a version in: $versionFile"} + $projectSettingsFile = [io.path]::Combine($path, "ProjectSettings\ProjectSettings.asset") + if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset"} + + $prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName'] + if (!$prodName) { throw "ProjectSettings is missing productName"} + $this.Path = $path $this.Version = $fileVersion + $this.ProductName = $prodName } } From 2febb70772f04b8b833d8179abdd75958d5aab92 Mon Sep 17 00:00:00 2001 From: Tim Gerken Date: Fri, 29 Mar 2019 17:13:37 +0000 Subject: [PATCH 2/2] Expose productName in UnityProjectInstance --- README.md | 12 ++++++------ UnitySetup/UnitySetup.psm1 | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b882b2d..422a355 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,12 @@ Find all the Unity projects recursively: Get-UnityProjectInstance -Recurse # Example output: -# Version Path -# ------- ---- -# 2017.2.0f3 C:\Projects\Project1\OneUnity\ -# 2017.3.0f3 C:\Projects\Project1\TwoUnity\ -# 2017.1.1p1 C:\Projects\Project2\ -# 2017.1.2f1 C:\Projects\Project3\App.Unity\ +# Version Path ProductName +# ------- ---- ----------- +# 2017.2.0f3 C:\Projects\Project1\OneUnity\ Contoso +# 2017.3.0f3 C:\Projects\Project1\TwoUnity\ Northwind +# 2017.1.1p1 C:\Projects\Project2\ My Cool App +# 2017.1.2f1 C:\Projects\Project3\App.Unity\ TemplateProject ``` Launch the right Unity editor for a project: ```powershell diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index c65758d..353526b 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -122,6 +122,7 @@ class UnitySetupInstance { class UnityProjectInstance { [UnityVersion]$Version [string]$Path + [string]$ProductName UnityProjectInstance([string]$path) { $versionFile = [io.path]::Combine($path, "ProjectSettings\ProjectVersion.txt") @@ -130,8 +131,15 @@ class UnityProjectInstance { $fileVersion = (Get-Content $versionFile -Raw | ConvertFrom-Yaml)['m_EditorVersion']; if (!$fileVersion) { throw "Project is missing a version in: $versionFile"} + $projectSettingsFile = [io.path]::Combine($path, "ProjectSettings\ProjectSettings.asset") + if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset"} + + $prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName'] + if (!$prodName) { throw "ProjectSettings is missing productName"} + $this.Path = $path $this.Version = $fileVersion + $this.ProductName = $prodName } }