|
1 | 1 | <Project Sdk="Microsoft.NET.Sdk"> |
2 | 2 | <PropertyGroup> |
3 | 3 | <TargetFramework>netstandard2.1</TargetFramework> |
4 | | - <!-- |
5 | | - In CI: Unity managed DLLs are extracted to lib/UnityEngine/ by the workflow. |
6 | | - Locally: set the UNITY_MANAGED_PATH environment variable to your Unity installation: |
7 | | - Windows: C:\Program Files\Unity\Hub\Editor\6000.0.73f1\Editor\Data\Managed\UnityEngine |
8 | | - macOS: /Applications/Unity/Hub/Editor/6000.0.73f1/Unity.app/Contents/Managed/UnityEngine |
9 | | - Linux: ~/Unity/Hub/Editor/6000.0.73f1/Editor/Data/Managed/UnityEngine |
10 | | - --> |
11 | | - <UnityManagedPath Condition="'$(UNITY_MANAGED_PATH)' != ''">$(UNITY_MANAGED_PATH)</UnityManagedPath> |
12 | | - <UnityManagedPath Condition="'$(UnityManagedPath)' == ''">lib/UnityEngine</UnityManagedPath> |
13 | 4 | </PropertyGroup> |
14 | 5 |
|
15 | 6 | <Target Name="AddUnityReferences" BeforeTargets="ResolveAssemblyReferences"> |
16 | | - <ItemGroup> |
| 7 | + <!-- |
| 8 | + Priority 1: UNITY_MANAGED_PATH environment variable (explicit override). |
| 9 | + Priority 2: lib/UnityEngine/ extracted by CI from the game-ci Docker image. |
| 10 | + Priority 3: auto-detect from default Unity Hub installation paths (glob over installed versions). |
| 11 | + If nothing is found, a MSBuild warning is emitted. |
| 12 | + --> |
| 13 | + |
| 14 | + <!-- Priorities 1 & 2: explicit path --> |
| 15 | + <PropertyGroup> |
| 16 | + <UnityManagedPath Condition="'$(UNITY_MANAGED_PATH)' != ''">$(UNITY_MANAGED_PATH)</UnityManagedPath> |
| 17 | + <UnityManagedPath Condition="'$(UnityManagedPath)' == '' and Exists('$(MSBuildProjectDirectory)/lib/UnityEngine')">$(MSBuildProjectDirectory)/lib/UnityEngine</UnityManagedPath> |
| 18 | + </PropertyGroup> |
| 19 | + |
| 20 | + <!-- Collect DLLs from explicit path (priorities 1 or 2) --> |
| 21 | + <ItemGroup Condition="'$(UnityManagedPath)' != ''"> |
17 | 22 | <_UnityDll Include="$(UnityManagedPath)/*.dll" /> |
| 23 | + </ItemGroup> |
| 24 | + |
| 25 | + <!-- Priority 3: auto-detect on Windows --> |
| 26 | + <ItemGroup Condition="'$(UnityManagedPath)' == '' and $([MSBuild]::IsOSPlatform('Windows'))"> |
| 27 | + <_UnityDll Include="C:\Program Files\Unity\Hub\Editor\*\Editor\Data\Managed\UnityEngine\*.dll" /> |
| 28 | + </ItemGroup> |
| 29 | + |
| 30 | + <!-- Priority 3: auto-detect on macOS --> |
| 31 | + <ItemGroup Condition="'$(UnityManagedPath)' == '' and $([MSBuild]::IsOSPlatform('OSX'))"> |
| 32 | + <_UnityDll Include="/Applications/Unity/Hub/Editor/*/Unity.app/Contents/Managed/UnityEngine/*.dll" /> |
| 33 | + </ItemGroup> |
| 34 | + |
| 35 | + <!-- Priority 3: auto-detect on Linux --> |
| 36 | + <ItemGroup Condition="'$(UnityManagedPath)' == '' and $([MSBuild]::IsOSPlatform('Linux'))"> |
| 37 | + <_UnityDll Include="$(HOME)/Unity/Hub/Editor/*/Editor/Data/Managed/UnityEngine/*.dll" /> |
| 38 | + </ItemGroup> |
| 39 | + |
| 40 | + <!-- Warning if no Unity DLLs found at all --> |
| 41 | + <Warning Condition="'@(_UnityDll)' == ''" |
| 42 | + Text="Unity managed DLLs not found. Set UNITY_MANAGED_PATH to your Unity installation's Managed/UnityEngine directory (e.g. /Applications/Unity/Hub/Editor/6000.0.73f1/Unity.app/Contents/Managed/UnityEngine), or install Unity Hub at its default location." /> |
| 43 | + |
| 44 | + <!-- Add assembly references for all discovered DLLs --> |
| 45 | + <ItemGroup> |
18 | 46 | <Reference Include="%(_UnityDll.Filename)"> |
19 | 47 | <HintPath>%(_UnityDll.FullPath)</HintPath> |
20 | 48 | <Private>false</Private> |
|
0 commit comments