private CSProjectInfo GetProjectInfo(Dictionary <string, CSProjectInfo> projectsMap, Dictionary <string, AssemblyDefinitionInfo> asmDefInfoMap, HashSet <string> builtInPackagesWithoutSource, string projectKey, string projectOutputPath) { if (projectsMap.TryGetValue(projectKey, out CSProjectInfo value)) { return(value); } if (!asmDefInfoMap.TryGetValue(projectKey, out AssemblyDefinitionInfo assemblyDefinitionInfo)) { Debug.LogError($"Can't find an asmdef for project: {projectKey}, this project may need to be to added to the PackageReferencesUnity2019 or ExcludedPackageReferences exclusion list"); throw new InvalidOperationException($"Can't find an asmdef for project: {projectKey}"); } CSProjectInfo toReturn = new CSProjectInfo(this, assemblyDefinitionInfo, projectOutputPath); projectsMap.Add(projectKey, toReturn); if (!assemblyDefinitionInfo.BuiltInPackage) { foreach (PluginAssemblyInfo plugin in Plugins.Where(t => t.Type != PluginType.Native)) { if (plugin.AutoReferenced || assemblyDefinitionInfo.PrecompiledAssemblyReferences.Contains(plugin.Name)) { toReturn.AddDependency(plugin); } } } foreach (string reference in toReturn.AssemblyDefinitionInfo.References) { if (ExcludedPackageReferences.Contains(reference)) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's marked as excluded."); continue; } #if !UNITY_2019_3_OR_NEWER if (PackageReferencesUnity2019.Contains(reference)) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's for Unity 2019.3+."); continue; } #endif string packageCandidate = $"com.{reference.ToLower()}"; if (builtInPackagesWithoutSource.Any(t => packageCandidate.StartsWith(t))) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's a built-in package without source."); continue; } toReturn.AddDependency(GetProjectInfo(projectsMap, asmDefInfoMap, builtInPackagesWithoutSource, reference, projectOutputPath)); } return(toReturn); }
private CSProjectInfo GetProjectInfo(Dictionary <string, CSProjectInfo> projectsMap, Dictionary <string, AssemblyDefinitionInfo> asmDefInfoMap, HashSet <string> builtInPackagesWithoutSource, string projectKey, string projectOutputPath) { #if UNITY_2019_3_OR_NEWER if (SpecialPluginNameMappingUnity2019.TryGetValue(projectKey, out string pluginName)) { projectKey = pluginName; } #endif if (projectsMap.TryGetValue(projectKey, out CSProjectInfo value)) { return(value); } if (!asmDefInfoMap.TryGetValue(projectKey, out AssemblyDefinitionInfo assemblyDefinitionInfo)) { Debug.LogError($"Can't find an asmdef for project: {projectKey}, this project may need to be to added to the PackageReferencesUnity2019 or ExcludedPackageReferences exclusion list"); throw new InvalidOperationException($"Can't find an asmdef for project: {projectKey}"); } CSProjectInfo toReturn = new CSProjectInfo(this, assemblyDefinitionInfo, projectOutputPath); projectsMap.Add(projectKey, toReturn); if (!assemblyDefinitionInfo.BuiltInPackage) { foreach (PluginAssemblyInfo plugin in Plugins.Where(t => t.Type != PluginType.Native)) { if (plugin.AutoReferenced || assemblyDefinitionInfo.PrecompiledAssemblyReferences.Contains(plugin.Name)) { toReturn.AddDependency(plugin); } } } foreach (string reference in toReturn.AssemblyDefinitionInfo.References) { if (ExcludedPackageReferences.Contains(reference)) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's marked as excluded."); continue; } #if !UNITY_2019_3_OR_NEWER if (PackageReferencesUnity2019.Contains(reference)) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's for Unity 2019.3+."); continue; } #endif string packageCandidate = $"com.{reference.ToLower()}"; if (builtInPackagesWithoutSource.Any(t => packageCandidate.StartsWith(t))) { Debug.LogWarning($"Skipping processing {reference} for {toReturn.Name}, as it's a built-in package without source."); continue; } toReturn.AddDependency(GetProjectInfo(projectsMap, asmDefInfoMap, builtInPackagesWithoutSource, reference, projectOutputPath)); } // Manually add special plugin dependencies to the projects #if UNITY_2019_3_OR_NEWER #if UNITY_2020_2_OR_NEWER if (toReturn.Name.StartsWith("Microsoft.MixedReality.Toolkit") || toReturn.Name.StartsWith("Unity.TextMeshPro")) #else if (toReturn.Name.StartsWith("Microsoft.MixedReality.Toolkit")) #endif { string[] plugins = SpecialPluginNameMappingUnity2019.Values.OrderByDescending(p => p).ToArray(); foreach (var plugin in plugins) { if (projectsMap.TryGetValue(plugin, out CSProjectInfo projectInfo)) { toReturn.AddDependency(projectInfo); } #if UNITY_2020_2_OR_NEWER else { CSProjectInfo newProjInfo = new CSProjectInfo(this, asmDefInfoMap[plugin], projectOutputPath); if (plugin == plugins[1]) { newProjInfo.AddDependency(projectsMap[plugins[0]]); } projectsMap.Add(plugin, newProjInfo); toReturn.AddDependency(newProjInfo); } #endif } } #endif return(toReturn); }