|
24 | 24 | <SentryWindowsArtifactsDestination>$(SentryArtifactsDestination)Windows/Sentry/</SentryWindowsArtifactsDestination> |
25 | 25 | </PropertyGroup> |
26 | 26 |
|
| 27 | + <PropertyGroup> |
| 28 | + <HubSecondaryInstallPathFile>$(AppData)\UnityHub\secondaryInstallPath.json</HubSecondaryInstallPathFile> |
| 29 | + <HubDefaultEditorFile>$(AppData)\UnityHub\defaultEditor.json</HubDefaultEditorFile> |
| 30 | + <HubDefaultEditor Condition="'$(HubDefaultEditor)' == ''"></HubDefaultEditor> |
| 31 | + <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">C:\Program Files\Unity\Hub\Editor</HubInstallDir> |
| 32 | + <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">\Applications\Unity\Hub\Editor</HubInstallDir> |
| 33 | + <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">$(Home)\Unity\Hub\Editor</HubInstallDir> |
| 34 | + <HubInstallDir Condition="!Exists('$(HubInstallDir)')"></HubInstallDir> |
| 35 | + </PropertyGroup> |
| 36 | + |
| 37 | + <Target Name="FindHub" |
| 38 | + Condition="'$(HubInstallDir)' == '' AND Exists('$(HubSecondaryInstallPathFile)')" |
| 39 | + Returns="$(HubInstallDir);$(HubDefaultEditor)"> |
| 40 | + |
| 41 | + <ReadLinesFromFile File="$(HubSecondaryInstallPathFile)"> |
| 42 | + <Output TaskParameter="Lines" ItemName="item1" /> |
| 43 | + </ReadLinesFromFile> |
| 44 | + |
| 45 | + <ReadLinesFromFile File="$(HubDefaultEditorFile)" Condition="Exists('$(HubDefaultEditorFile)')"> |
| 46 | + <Output TaskParameter="Lines" ItemName="item2" /> |
| 47 | + </ReadLinesFromFile> |
| 48 | + |
| 49 | + <PropertyGroup> |
| 50 | + <HubInstallDir>@(item1->Replace('"', ''))</HubInstallDir> |
| 51 | + <HubInstallDir Condition=" !Exists('$(HubInstallDir)') "></HubInstallDir> |
| 52 | + |
| 53 | + <HubDefaultEditor>@(item2->Replace('"', ''))</HubDefaultEditor> |
| 54 | + <HubDefaultEditor Condition=" !Exists('$(HubInstallDir)\$(HubDefaultEditor)') "></HubDefaultEditor> |
| 55 | + </PropertyGroup> |
| 56 | + </Target> |
| 57 | + |
27 | 58 | <!-- Use the Unity Editor version set in the sample project of the repo --> |
28 | | - <Target Name="FindUnity"> |
| 59 | + <Target Name="FindUnity" DependsOnTargets="FindHub" AfterTargets="FindHub"> |
29 | 60 | <Message Text="Unity Version: $(UnityVersion)" Importance="Normal" /> |
30 | 61 |
|
| 62 | + <!-- Find all the installations of Unity done by the Unity Hub --> |
| 63 | + <ItemGroup Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' == ''"> |
| 64 | + <_AllUnityInstallDirs Include="$([System.IO.Directory]::GetDirectories('$(HubInstallDir)'))" /> |
| 65 | + <_UnityInstalls Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Filename)', '^[\d]{4}.*$'))" Include="@(_AllUnityInstallDirs->'%(Filename)%(Extension)')" /> |
| 66 | + </ItemGroup> |
| 67 | + |
| 68 | + <!-- Pick the latest one if this version of the Hub doesn't record a default version --> |
| 69 | + <PropertyGroup Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' == ''"> |
| 70 | + <HubDefaultEditor>%(_UnityInstalls.Identity)</HubDefaultEditor> |
| 71 | + </PropertyGroup> |
| 72 | + |
| 73 | + <PropertyGroup> |
| 74 | + <_UnityInnerPath Condition="!$([MSBuild]::IsOSPlatform('OSX'))">Editor\Data</_UnityInnerPath> |
| 75 | + <_UnityInnerPath Condition="$([MSBuild]::IsOSPlatform('OSX'))">Unity.App\Contents</_UnityInnerPath> |
| 76 | + </PropertyGroup> |
| 77 | + |
| 78 | + <ItemGroup> |
| 79 | + <_PotentialUnityPaths Condition="'$(HubInstallDir)' != ''" Include="$(HubInstallDir)\$(UnityVersion)\$(_UnityInnerPath)\Managed\UnityEngine.dll" /> |
| 80 | + <_PotentialUnityPaths Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' != '' AND '$(UnityVersion)' != '$(HubDefaultEditor)'" Include="$(HubInstallDir)\$(HubDefaultEditor)\$(_UnityInnerPath)\Managed\UnityEngine.dll" /> |
| 81 | + <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="C:\Program Files\Unity\$(_UnityInnerPath)\Managed\UnityEngine.dll" /> |
| 82 | + <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="\Applications\Unity\$(_UnityInnerPath)\Managed\UnityEngine.dll" /> |
| 83 | + <_UnityPathsFound Include="@(_PotentialUnityPaths->Exists())" /> |
| 84 | + <_UnityPathsFoundReversed Include="@(_UnityPathsFound->Reverse())" /> |
| 85 | + </ItemGroup> |
| 86 | + |
| 87 | + <PropertyGroup> |
| 88 | + <!--This is a little hack to grab the first item found on the list - properties are repeatedly set for each item on the list, so they end up with the last one (we reversed the list so we get the first one) --> |
| 89 | + <_UnityPathProp>%(_UnityPathsFoundReversed.Identity)</_UnityPathProp> |
| 90 | + </PropertyGroup> |
| 91 | + |
| 92 | + <ItemGroup> |
| 93 | + <!-- Turn the property back into an item so we can use DirectoryName() below. --> |
| 94 | + <_UnityPath Include="$(_UnityPathProp)" /> |
| 95 | + </ItemGroup> |
| 96 | + |
| 97 | + <PropertyGroup Condition="'$(_UnityPathProp)' != ''"> |
| 98 | + <UnityManagedPath>@(_UnityPath->DirectoryName())\</UnityManagedPath> |
| 99 | + <UnityDataPath>@(_UnityPath->DirectoryName()->DirectoryName())\</UnityDataPath> |
| 100 | + <UnityRoot>@(_UnityPath->DirectoryName()->DirectoryName()->DirectoryName())\</UnityRoot> |
| 101 | + <UnityLibcache>$(UnityDataPath)Resources\PackageManager\ProjectTemplates\libcache\</UnityLibcache> |
| 102 | + </PropertyGroup> |
| 103 | + |
| 104 | + <Error Condition="'$(UnityRoot)' == ''" Text="UnityRoot not found. Ensure Unity is installed. |
| 105 | +See the CONTRIBUTING.md. |
| 106 | +UnityVersion: '$(UnityVersion)' |
| 107 | +Expected to exist: |
| 108 | +* @(_PotentialUnityPaths, '%0a or %0a * ')" /> |
| 109 | + |
| 110 | + |
31 | 111 | <!-- Unity paths on Windows --> |
32 | 112 | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))"> |
33 | | - <UnityRoot Condition="Exists('C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\</UnityRoot> |
34 | | - <!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine--> |
35 | | - <UnityRoot Condition="$(UnityRoot) == '' AND Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Editor</UnityRoot> |
36 | | - <UnityLibcache>$(UnityRoot)Data/Resources/PackageManager/ProjectTemplates/libcache/</UnityLibcache> |
37 | | - <UnityManagedPath>$(UnityRoot)\Data\Managed</UnityManagedPath> |
38 | 113 | <UnityExec>"$(UnityRoot)\Unity.exe"</UnityExec> |
39 | 114 | <StandaloneBuildMethod>Builder.BuildWindowsIl2CPPPlayer</StandaloneBuildMethod> |
40 | 115 | <StandaloneBuildPath>$(PlayerBuildPath)Windows/IL2CPP_Player.exe</StandaloneBuildPath> |
41 | 116 | <StandaloneExecutablePath>$(StandaloneBuildPath)</StandaloneExecutablePath> |
42 | 117 | <StandaloneDataPath>$(USERPROFILE)/AppData/LocalLow/DefaultCompany/unity-of-bugs/</StandaloneDataPath> |
43 | 118 | </PropertyGroup> |
44 | 119 |
|
45 | | - <Error Condition="!Exists('$(UnityRoot)') AND $([MSBuild]::IsOSPlatform('Windows'))" Text="UnityRoot not found. Ensure Unity is installed. |
46 | | -See the CONTRIBUTING.md. |
47 | | -UnityVersion: '$(UnityVersion)' |
48 | | -Resolved directory: '$(UnityRoot)' |
49 | | -Expected to exist: |
50 | | - * C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed\UnityEngine.dll |
51 | | -or |
52 | | - * C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll" /> |
53 | 120 |
|
54 | 121 | <!-- Unity paths on macOS --> |
55 | 122 | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))"> |
56 | | - <UnityRoot Condition="Exists('/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/</UnityRoot> |
57 | | - <!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine--> |
58 | | - <UnityRoot Condition="$(UnityRoot) == '' AND Exists('/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Unity.app/</UnityRoot> |
59 | | - <UnityLibcache>$(UnityRoot)Contents/Resources/PackageManager/ProjectTemplates/libcache/</UnityLibcache> |
60 | | - <UnityManagedPath>$(UnityRoot)Contents/Managed</UnityManagedPath> |
61 | 123 | <UnityExec>"$(UnityRoot)Contents/MacOS/Unity"</UnityExec> |
62 | 124 | <StandaloneBuildMethod>Builder.BuildMacIl2CPPPlayer</StandaloneBuildMethod> |
63 | 125 | <StandaloneBuildPath>$(PlayerBuildPath)MacOS/IL2CPP_Player.app</StandaloneBuildPath> |
64 | 126 | <StandaloneExecutablePath>$(StandaloneBuildPath)/Contents/MacOS/unity-of-bugs</StandaloneExecutablePath> |
65 | 127 | </PropertyGroup> |
66 | 128 |
|
67 | | - <Error Condition="!Exists('$(UnityRoot)') AND $([MSBuild]::IsOSPlatform('OSX'))" Text="UnityRoot not found. Ensure Unity is installed. |
68 | | -See the CONTRIBUTING.md. |
69 | | -UnityVersion: '$(UnityVersion)' |
70 | | -Resolved directory: '$(UnityRoot)' |
71 | | -Expected to exist: |
72 | | - * /Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/UnityEngine.dll |
73 | | -or |
74 | | - * /Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll" /> |
75 | 129 |
|
76 | 130 | <!-- Unity paths on Linux --> |
77 | 131 | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))"> |
78 | | - <UnityRoot Condition="Exists('$(Home)/Unity/Hub/Editor/$(UnityVersion)/Editor/Data/Managed/UnityEngine.dll')">$(Home)/Unity/Hub/Editor/$(UnityVersion)/Editor/</UnityRoot> |
79 | | - <UnityRoot Condition="$(UNITY_PATH) != ''">$(UNITY_PATH)/Editor/</UnityRoot> |
80 | | - <UnityLibcache>$(UnityRoot)Data/Resources/PackageManager/ProjectTemplates/libcache/</UnityLibcache> |
81 | | - <UnityManagedPath>$(UnityRoot)Data/Managed</UnityManagedPath> |
82 | 132 | <UnityExec>xvfb-run -ae /dev/stdout "$(UnityRoot)Unity"</UnityExec> |
83 | 133 | <StandaloneBuildMethod>Builder.BuildLinuxIl2CPPPlayer</StandaloneBuildMethod> |
84 | 134 | <StandaloneBuildPath>$(PlayerBuildPath)Linux/IL2CPP_Player</StandaloneBuildPath> |
85 | 135 | <StandaloneExecutablePath>$(StandaloneBuildPath)</StandaloneExecutablePath> |
86 | 136 | </PropertyGroup> |
87 | 137 |
|
88 | | - <Error Condition="!Exists('$(UnityRoot)') AND $([MSBuild]::IsOSPlatform('Linux'))" Text="UnityRoot not found. Ensure Unity is installed. |
89 | | -See the CONTRIBUTING.md. |
90 | | -UnityVersion: '$(UnityVersion)' |
91 | | -Resolved directory: '$(UnityRoot)' |
92 | | -Expected to exist: |
93 | | - * $(Home)/Unity/Hub/Editor/$(UnityVersion)/Editor/Data/Managed/UnityEngine.dll" /> |
94 | 138 |
|
95 | 139 | <LocateTestRunner UnityLibcache="$(UnityLibcache)"> |
96 | 140 | <Output PropertyName="TestRunnerPath" TaskParameter="TestRunnerPath" /> |
|
0 commit comments