|
25 | 25 | <SentryWindowsArtifactsDestination>$(SentryArtifactsDestination)Windows/Sentry/</SentryWindowsArtifactsDestination> |
26 | 26 | </PropertyGroup> |
27 | 27 |
|
28 | | - <PropertyGroup> |
29 | | - <HubSecondaryInstallPathFile>$(AppData)\UnityHub\secondaryInstallPath.json</HubSecondaryInstallPathFile> |
30 | | - <HubDefaultEditorFile>$(AppData)\UnityHub\defaultEditor.json</HubDefaultEditorFile> |
31 | | - <HubDefaultEditor Condition="'$(HubDefaultEditor)' == ''"></HubDefaultEditor> |
32 | | - <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">C:\Program Files\Unity\Hub\Editor</HubInstallDir> |
33 | | - <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">\Applications\Unity\Hub\Editor</HubInstallDir> |
34 | | - <HubInstallDir Condition="'$(HubInstallDir)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">$(Home)\Unity\Hub\Editor</HubInstallDir> |
35 | | - <HubInstallDir Condition="!Exists('$(HubInstallDir)')"></HubInstallDir> |
36 | | - </PropertyGroup> |
37 | | - |
38 | | - <Target Name="FindHub" |
39 | | - Condition="'$(HubInstallDir)' == '' AND Exists('$(HubSecondaryInstallPathFile)')" |
40 | | - Returns="$(HubInstallDir);$(HubDefaultEditor)"> |
41 | | - |
42 | | - <ReadLinesFromFile File="$(HubSecondaryInstallPathFile)"> |
43 | | - <Output TaskParameter="Lines" ItemName="item1" /> |
44 | | - </ReadLinesFromFile> |
45 | | - |
46 | | - <ReadLinesFromFile File="$(HubDefaultEditorFile)" Condition="Exists('$(HubDefaultEditorFile)')"> |
47 | | - <Output TaskParameter="Lines" ItemName="item2" /> |
48 | | - </ReadLinesFromFile> |
49 | | - |
50 | | - <PropertyGroup> |
51 | | - <HubInstallDir>@(item1->Replace('"', ''))</HubInstallDir> |
52 | | - <HubInstallDir Condition=" !Exists('$(HubInstallDir)') "></HubInstallDir> |
53 | | - |
54 | | - <HubDefaultEditor>@(item2->Replace('"', ''))</HubDefaultEditor> |
55 | | - <HubDefaultEditor Condition=" !Exists('$(HubInstallDir)\$(HubDefaultEditor)') "></HubDefaultEditor> |
56 | | - </PropertyGroup> |
57 | | - </Target> |
58 | | - |
59 | | - <!-- Use the Unity Editor version set in the sample project of the repo --> |
60 | | - <Target Name="FindUnity" DependsOnTargets="FindHub" AfterTargets="FindHub"> |
| 28 | + <Target Name="FindUnity"> |
61 | 29 | <Message Text="Unity Version: $(UnityVersion)" Importance="Normal" /> |
62 | 30 |
|
63 | | - <!-- Find all the installations of Unity done by the Unity Hub --> |
64 | | - <ItemGroup Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' == ''"> |
65 | | - <_AllUnityInstallDirs Include="$([System.IO.Directory]::GetDirectories('$(HubInstallDir)'))" /> |
66 | | - <_UnityInstalls Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Filename)', '^[\d]{4}.*$'))" Include="@(_AllUnityInstallDirs->'%(Filename)%(Extension)')" /> |
67 | | - </ItemGroup> |
68 | | - |
69 | | - <!-- Pick the latest one if this version of the Hub doesn't record a default version --> |
70 | | - <PropertyGroup Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' == ''"> |
71 | | - <HubDefaultEditor>%(_UnityInstalls.Identity)</HubDefaultEditor> |
72 | | - </PropertyGroup> |
73 | | - |
74 | | - <PropertyGroup> |
75 | | - <_UnityInnerPath Condition="!$([MSBuild]::IsOSPlatform('OSX'))">Editor\Data</_UnityInnerPath> |
76 | | - <_UnityInnerPath Condition="$([MSBuild]::IsOSPlatform('OSX'))">Unity.App\Contents</_UnityInnerPath> |
77 | | - </PropertyGroup> |
78 | | - |
79 | | - <ItemGroup> |
80 | | - <!-- Unity 6000.3+ relocated managed assemblies under Resources\Scripting\Managed. |
81 | | - Each candidate carries Root metadata so the post-selection block doesn't have |
82 | | - to reverse-engineer the layout. New layout is probed first within each slot. --> |
83 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(UNITY_PATH)' != ''" |
84 | | - Include="$(UNITY_PATH)\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll" |
85 | | - Root="$(UNITY_PATH)\" /> |
86 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(UNITY_PATH)' != ''" |
87 | | - Include="$(UNITY_PATH)\$(_UnityInnerPath)\Managed\UnityEngine.dll" |
88 | | - Root="$(UNITY_PATH)\" /> |
89 | | - |
90 | | - <_PotentialUnityPaths Condition="'$(HubInstallDir)' != ''" |
91 | | - Include="$(HubInstallDir)\$(UnityVersion)\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll" |
92 | | - Root="$(HubInstallDir)\$(UnityVersion)\" /> |
93 | | - <_PotentialUnityPaths Condition="'$(HubInstallDir)' != ''" |
94 | | - Include="$(HubInstallDir)\$(UnityVersion)\$(_UnityInnerPath)\Managed\UnityEngine.dll" |
95 | | - Root="$(HubInstallDir)\$(UnityVersion)\" /> |
96 | | - |
97 | | - <_PotentialUnityPaths Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' != '' AND '$(UnityVersion)' != '$(HubDefaultEditor)'" |
98 | | - Include="$(HubInstallDir)\$(HubDefaultEditor)\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll" |
99 | | - Root="$(HubInstallDir)\$(HubDefaultEditor)\" /> |
100 | | - <_PotentialUnityPaths Condition="'$(HubInstallDir)' != '' AND '$(HubDefaultEditor)' != '' AND '$(UnityVersion)' != '$(HubDefaultEditor)'" |
101 | | - Include="$(HubInstallDir)\$(HubDefaultEditor)\$(_UnityInnerPath)\Managed\UnityEngine.dll" |
102 | | - Root="$(HubInstallDir)\$(HubDefaultEditor)\" /> |
103 | | - |
104 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('Windows'))" |
105 | | - Include="C:\Program Files\Unity\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll" |
106 | | - Root="C:\Program Files\Unity\" /> |
107 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('Windows'))" |
108 | | - Include="C:\Program Files\Unity\$(_UnityInnerPath)\Managed\UnityEngine.dll" |
109 | | - Root="C:\Program Files\Unity\" /> |
110 | | - |
111 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('OSX'))" |
112 | | - Include="\Applications\Unity\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll" |
113 | | - Root="\Applications\Unity\" /> |
114 | | - <_PotentialUnityPaths Condition="$([MSBuild]::IsOSPlatform('OSX'))" |
115 | | - Include="\Applications\Unity\$(_UnityInnerPath)\Managed\UnityEngine.dll" |
116 | | - Root="\Applications\Unity\" /> |
117 | | - |
118 | | - <_UnityPathsFound Include="@(_PotentialUnityPaths->Exists())" /> |
119 | | - <_UnityPathsFoundReversed Include="@(_UnityPathsFound->Reverse())" /> |
120 | | - </ItemGroup> |
| 31 | + <Exec |
| 32 | + Command="pwsh -NoProfile -File "$(RepoRoot)scripts/find-unity.ps1" -UnityVersion "$(UnityVersion)" -HubInstallDir "$(HubInstallDir)" -HubDefaultEditor "$(HubDefaultEditor)"" |
| 33 | + ConsoleToMSBuild="true"> |
| 34 | + <Output TaskParameter="ConsoleOutput" PropertyName="_FindUnityOutput" /> |
| 35 | + </Exec> |
121 | 36 |
|
122 | 37 | <PropertyGroup> |
123 | | - <!-- "Last one wins" trick — reversed list yields the first match. Metadata rides along. --> |
124 | | - <_UnityPathProp>%(_UnityPathsFoundReversed.Identity)</_UnityPathProp> |
125 | | - <_UnityRootProp>%(_UnityPathsFoundReversed.Root)</_UnityRootProp> |
| 38 | + <UnityRoot>$([System.Text.RegularExpressions.Regex]::Match($(_FindUnityOutput), 'UnityRoot=([^;\r\n]+)').Groups[1].Value)</UnityRoot> |
| 39 | + <UnityDataPath>$([System.Text.RegularExpressions.Regex]::Match($(_FindUnityOutput), 'UnityDataPath=([^;\r\n]+)').Groups[1].Value)</UnityDataPath> |
| 40 | + <UnityManagedPath>$([System.Text.RegularExpressions.Regex]::Match($(_FindUnityOutput), 'UnityManagedPath=([^;\r\n]+)').Groups[1].Value)</UnityManagedPath> |
| 41 | + <UnityLibcache>$(UnityDataPath)Resources/PackageManager/ProjectTemplates/libcache/</UnityLibcache> |
126 | 42 | </PropertyGroup> |
127 | 43 |
|
128 | | - <Message |
129 | | - Condition="'$(UnityVersion)' != '' AND '$(HubInstallDir)' != '' |
130 | | - AND !Exists('$(HubInstallDir)\$(UnityVersion)\$(_UnityInnerPath)\Managed\UnityEngine.dll') |
131 | | - AND !Exists('$(HubInstallDir)\$(UnityVersion)\$(_UnityInnerPath)\Resources\Scripting\Managed\UnityEngine.dll') |
132 | | - AND '$(_UnityPathProp)' != ''" |
133 | | - Text="Unity version $(UnityVersion) is not installed. Falling back to default Unity installation." |
134 | | - Importance="High" /> |
135 | | - |
136 | | - <ItemGroup> |
137 | | - <!-- Turn the property back into an item so we can use DirectoryName() below. --> |
138 | | - <_UnityPath Include="$(_UnityPathProp)" /> |
139 | | - </ItemGroup> |
140 | | - |
141 | | - <PropertyGroup Condition="'$(_UnityPathProp)' != ''"> |
142 | | - <UnityRoot>$(_UnityRootProp)</UnityRoot> |
143 | | - <UnityDataPath>$(UnityRoot)$(_UnityInnerPath)\</UnityDataPath> |
144 | | - <UnityManagedPath>@(_UnityPath->DirectoryName())\</UnityManagedPath> |
145 | | - <UnityLibcache>$(UnityDataPath)Resources\PackageManager\ProjectTemplates\libcache\</UnityLibcache> |
146 | | - </PropertyGroup> |
147 | | - |
148 | | - <Error Condition="'$(UnityRoot)' == ''" Text="UnityRoot not found. Ensure Unity is installed. |
149 | | -See the CONTRIBUTING.md. |
150 | | -UnityVersion: '$(UnityVersion)' |
151 | | -Expected to exist: |
152 | | -* @(_PotentialUnityPaths, '%0a or %0a * ')" /> |
153 | | - |
| 44 | + <Error Condition="'$(UnityRoot)' == ''" Text="UnityRoot not resolved — see scripts/find-unity.ps1 output above." /> |
154 | 45 |
|
155 | 46 | <!-- Unity paths on Windows --> |
156 | 47 | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))"> |
|
0 commit comments