private string GetProjectEntry(CSProjectInfo projectInfo, string projectEntryTemplateBody) { StringBuilder toReturn = new StringBuilder(); toReturn.AppendLine(Utilities.ReplaceTokens(projectEntryTemplateBody, new Dictionary <string, string>() { { "<PROJECT_NAME>", projectInfo.Name }, { "<PROJECT_RELATIVE_PATH>", Path.GetFileName(projectInfo.ReferencePath.AbsolutePath) }, { "<PROJECT_GUID>", projectInfo.Guid.ToString().ToUpper() } })); if (projectInfo.ProjectDependencies.Count > 0) { string projectDependencyStartSection = " ProjectSection(ProjectDependencies) = postProject"; string projectDependencyGuid = " {<DependencyGuid>} = {<DependencyGuid>}"; string projectDependencyStopSection = " EndProjectSection"; toReturn.AppendLine(projectDependencyStartSection); foreach (CSProjectDependency <CSProjectInfo> project in projectInfo.ProjectDependencies) { toReturn.AppendLine(projectDependencyGuid.Replace("<DependencyGuid>", project.Dependency.Guid.ToString().ToUpper())); } toReturn.AppendLine(projectDependencyStopSection); } toReturn.Append("EndProject"); return(toReturn.ToString()); }
private CSProjectInfo GetProjectInfo(Dictionary <string, CSProjectInfo> projectsMap, Dictionary <string, AssemblyDefinitionInfo> asmDefInfoMap, HashSet <string> builtInPackagesWithoutSource, string projectKey) { if (projectKey.StartsWith("GUID:")) { projectKey = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(projectKey.Substring("GUID:".Length))); } if (projectsMap.TryGetValue(projectKey, out CSProjectInfo value)) { return(value); } 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); } CSProjectInfo toReturn = new CSProjectInfo(this, assemblyDefinitionInfo); projectsMap.Add(projectKey, toReturn); if (!assemblyDefinitionInfo.BuiltInPackage) { Uri dependencies = new Uri(Path.Combine(Utilities.AssetPath, "Dependencies")); foreach (PluginAssemblyInfo plugin in Plugins.Where(t => t.Type != PluginType.Native)) { if (!dependencies.IsBaseOf(plugin.ReferencePath) && (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; } 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; } CSProjectInfo dependencyToAdd = GetProjectInfo(projectsMap, asmDefInfoMap, builtInPackagesWithoutSource, reference); if (dependencyToAdd != null) { toReturn.AddDependency(dependencyToAdd); } } return(toReturn); }
///<inherit-doc/> public static FileInfo GetProjectPath(CSProjectInfo projectInfo, DirectoryInfo generatedProjectFolder) { switch (projectInfo.AssemblyDefinitionInfo.AssetLocation) { case AssetLocation.BuiltInPackage: case AssetLocation.External: case AssetLocation.PackageLibraryCache: return(new FileInfo(GetProjectFilePath(generatedProjectFolder, projectInfo))); case AssetLocation.Project: case AssetLocation.Package: return(new FileInfo(GetProjectFilePath(projectInfo.AssemblyDefinitionInfo.Directory, projectInfo))); default: throw new InvalidOperationException("The project's assembly definition file is in an unknown location."); } }
private SolutionProject CreateSolutionProjectEntry(CSProjectInfo project, Uri relativePath, SolutionFileInfo solutionFileInfo) { IEnumerable <SolutionSection> sections = null; if (solutionFileInfo.Projects.TryGetValue(project.Guid, out Project parsedProject)) { sections = parsedProject.Sections; } SolutionProject toReturn = new SolutionProject(project.Guid, SolutionProject.CSharpProjectTypeGuid, project.Name + ".msb4u", relativePath, sections, project.ProjectDependencies.Select(t => t.Dependency.Guid)); foreach (CompilationPlatformInfo platform in AvailablePlatforms) { ProcessConfigurationPlatformMapping(toReturn, UnityConfigurationType.InEditor, platform, project.InEditorPlatforms); ProcessConfigurationPlatformMapping(toReturn, UnityConfigurationType.Player, platform, project.PlayerPlatforms); } SetAdditionalProjectProperties(toReturn, project.Guid, solutionFileInfo); return(toReturn); }
/// <summary> /// Adds a dependency to the project. /// </summary> /// <param name="csProjectInfo">The C# dependency.</param> internal void AddDependency(CSProjectInfo csProjectInfo) { AddDependency(csProjectDependencies, csProjectInfo); }
private static string GetProjectFilePath(DirectoryInfo directory, CSProjectInfo projectInfo) { return(GetProjectFilePath(directory.FullName, projectInfo.Name)); }