Skip to content

Commit 36c678a

Browse files
claudeNormandErwan
authored andcommitted
fix: reference all Unity managed DLLs via MSBuild glob
DocFX v2 requires Roslyn to resolve Unity types (MonoBehaviour, AudioClip, etc.) to their fully-qualified UIDs before the xref map can link them to docs.unity3d.com. Without assembly references, crefs become !:AudioClip which never matches the xref map. A MSBuild Target globs all *.dll from $(UnityManagedPath) (defaulting to lib/UnityEngine/, populated by CI) so users never need to manually add <Reference> entries when new Unity types are used in their scripts. UNITY_MANAGED_PATH env var allows pointing to a local Unity installation for development without running Docker. .gitignore: replace broad *.csproj + negation with specific Unity-generated patterns (Assembly-CSharp*.csproj) so DocFxForUnity.csproj stays tracked without a fragile negation rule. Add lib/ to ignore extracted DLLs. https://claude.ai/code/session_01N4YoJdJc2JDaoAbk5Nt8vf
1 parent 9512d69 commit 36c678a

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ Packages/*
3030
## Autogenerated VS/MD/Consulo solution and project files
3131
ExportedObj/
3232
.consulo/
33-
*.csproj
34-
!DocFxForUnity.csproj
33+
Assembly-CSharp*.csproj
34+
Assembly-CSharp-Editor*.csproj
35+
lib/
3536
*.unityproj
3637
*.sln
3738
*.suo

DocFxForUnity.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<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>
413
</PropertyGroup>
14+
15+
<Target Name="AddUnityReferences" BeforeTargets="ResolveAssemblyReferences">
16+
<ItemGroup>
17+
<_UnityDll Include="$(UnityManagedPath)/*.dll" />
18+
<Reference Include="%(_UnityDll.Filename)">
19+
<HintPath>%(_UnityDll.FullPath)</HintPath>
20+
<Private>false</Private>
21+
</Reference>
22+
</ItemGroup>
23+
</Target>
524
</Project>

0 commit comments

Comments
 (0)