fix(csproj): auto-detect Unity Hub DLLs on Windows/macOS/Linux#33
Merged
Conversation
If UNITY_MANAGED_PATH is not set and lib/UnityEngine/ does not exist (CI path), the target now falls back to OS-specific glob patterns over the default Unity Hub installation directory (*-wildcard on version). A MSBuild Warning is emitted when no DLL is found after all three resolution steps, replacing the previous silent failure. https://claude.ai/code/session_01DctbQWKKrBNCfvBuKsu5ad
…PATH - Add DocFxForUnity.csproj to the list of files to copy in setup step 2, with a note on renaming and updating docfx.json - Replace the outdated "Assets > Open C# Project" troubleshooting tip with instructions matching the committed .csproj approach - Add a "Unity managed DLLs not found" FAQ entry describing the three-step resolution order (env var → lib/ → OS glob) - Add a new "Advanced: UNITY_MANAGED_PATH" section with per-OS paths and shell snippets for overriding the auto-detected Unity version - Update xref version examples from 2017/2018/2019 to current versions https://claude.ai/code/session_01DctbQWKKrBNCfvBuKsu5ad
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Previously,
DocFxForUnity.csprojresolved Unity DLLs in only two ways:UNITY_MANAGED_PATHenv var if setlib/UnityEngine(the CI path)A developer without
UNITY_MANAGED_PATHdefined and nolib/UnityEnginefolder (i.e. anyone who hasn't run the CI workflow locally) would silently get an empty reference list — no Unity types resolved, no xref links, no error message explaining why.This is linked to issues #28, #14, #15, and #12.
Solution
All path resolution logic is moved inside the
AddUnityReferencestarget (evaluated at build time). Three-level priority chain:UNITY_MANAGED_PATHenv varlib/UnityEngine/Exists()If no DLL is found after all three steps, a MSBuild
<Warning>is emitted with a clear, actionable message.Auto-detection paths (priority 3)
C:\Program Files\Unity\Hub\Editor\*\Editor\Data\Managed\UnityEngine\*.dll/Applications/Unity/Hub/Editor/*/Unity.app/Contents/Managed/UnityEngine/*.dll$(HOME)/Unity/Hub/Editor/*/Editor/Data/Managed/UnityEngine/*.dllThe
*wildcard covers any Unity version installed via Unity Hub — no version pinning required in the.csproj.Test plan
lib/UnityEngine/; priority 2 fires, no regressionUNITY_MANAGED_PATH— priority 1 fires, same behaviour as beforedotnet build -v:normalshows no warning@(_UnityDll)is empty; MSBuild warning is visible in build outputhttps://claude.ai/code/session_01DctbQWKKrBNCfvBuKsu5ad
Generated by Claude Code