From b6e0bb89469e4f399ddaa9a4a98bc856646bdbac Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Thu, 9 Jan 2020 12:00:20 -0800 Subject: [PATCH] add project aliases for weird unity packages --- .../Scripts/UnityProjectInfo.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs index af4ea3b..5906df7 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs @@ -26,6 +26,14 @@ public class UnityProjectInfo : IDisposable "Windows.UI.Input.Spatial" }; + /// + /// For some Unity packages, references don't match the appropriate asmdef name. + /// + private static readonly Dictionary ProjectAliases = new Dictionary() + { + { "Unity.ugui", "UnityEngine.UI" } + }; + /// /// Gets the name of this Unity Project. /// @@ -261,8 +269,16 @@ private CSProjectInfo GetProjectInfo(Dictionary projectsM if (!asmDefInfoMap.TryGetValue(projectKey, out AssemblyDefinitionInfo assemblyDefinitionInfo)) { - Debug.Log($"Can't find an asmdef for project: {projectKey}; Unity actually allows this, so proceeding."); - return null; + if (ProjectAliases.TryGetValue(projectKey, out string projectAlias) && asmDefInfoMap.TryGetValue(projectAlias, out assemblyDefinitionInfo)) + { + Debug.Log($"A reference was found for {projectKey}, which has known project alias ({projectAlias}). References were made to {projectAlias} instead of {projectKey}."); + projectKey = projectAlias; + } + else + { + Debug.Log($"Can't find an asmdef for project: {projectKey}; Unity actually allows this, so proceeding."); + return null; + } } CSProjectInfo toReturn = new CSProjectInfo(this, assemblyDefinitionInfo);