/// <summary> /// Get the array of files to compile from all packages. /// </summary> /// <returns>The script files.</returns> /// <param name="allBuilders">If set to <c>true</c> all builders.</param> public StringArray GetScriptFiles( bool allBuilders = false) { var bamDir = this.GetBamDirectory(); var scriptDir = System.IO.Path.Combine(bamDir, PackageUtilities.ScriptsSubFolder); var scripts = new StringArray(System.IO.Directory.GetFiles(scriptDir, "*.cs", System.IO.SearchOption.AllDirectories)); var builderNames = new StringArray(); if (allBuilders) { foreach (var package in Graph.Instance.Packages) { if (!BuildModeUtilities.IsBuildModePackage(package.Name)) { continue; } builderNames.Add(package.Name); } } else { builderNames.AddUnique(System.String.Format("{0}Builder", Graph.Instance.Mode)); } foreach (var builderName in builderNames) { var builderScriptDir = System.IO.Path.Combine(bamDir, builderName); if (System.IO.Directory.Exists(builderScriptDir)) { scripts.AddRange(System.IO.Directory.GetFiles(builderScriptDir, "*.cs", System.IO.SearchOption.AllDirectories)); } } return scripts; }
/// <summary> /// Based on the dependents lists in the XML file, resolve all dependents by reading more /// package definition files. /// </summary> /// <param name="current">Current.</param> /// <param name="authenticated">Authenticated.</param> /// <param name="candidatePackageDefinitions">Candidate package definitions.</param> public static void ResolveDependencies( PackageDefinition current, Array<PackageDefinition> authenticated, Array<PackageDefinition> candidatePackageDefinitions) { var matchingPackages = authenticated.Where(item => item.Name == current.Name); if (null != current.Version) { matchingPackages = matchingPackages.Where(item => item.Version == current.Version); } if (matchingPackages.FirstOrDefault() != null) { return; } if (!current.SupportedPlatforms.Includes(OSUtilities.CurrentOS)) { throw new Exception("Package {0} is not supported on {1}", current.FullName, OSUtilities.CurrentOS.ToString()); } authenticated.Add(current); foreach (var dependent in current.Dependents) { var depName = dependent.Item1; var depVersion = dependent.Item2; var candidates = candidatePackageDefinitions.Where(item => item.Name == depName); if (depVersion != null) { candidates = candidates.Where(item => item.Version == depVersion); } var candidateCount = candidates.Count(); if (0 == candidateCount) { var message = new System.Text.StringBuilder(); message.AppendFormat("Unable to find a candidate package with name '{0}'", depName); if (null != depVersion) { message.AppendFormat(" and version {0}", depVersion); } message.AppendLine(); var packageRepos = new StringArray(); Graph.Instance.PackageRepositories.ToList().ForEach(item => packageRepos.AddUnique(item)); message.AppendLine("Searched in the package repositories:"); message.AppendLine(packageRepos.ToString("\n")); throw new Exception(message.ToString()); } if (candidateCount > 1) { var message = new System.Text.StringBuilder(); message.AppendFormat("There are {0} identical candidate packages with name '{1}'", candidateCount, depName); if (null != depVersion) { message.AppendFormat(" and version {0}", depVersion); } message.AppendLine(" from the following package definition files:"); foreach (var candidate in candidates) { message.AppendFormat(candidate.XMLFilename); message.AppendLine(); } var packageRepos = new StringArray(); Graph.Instance.PackageRepositories.ToList().ForEach(item => packageRepos.AddUnique(item)); message.AppendLine("Found in the package repositories:"); message.AppendLine(packageRepos.ToString("\n")); throw new Exception(message.ToString()); } ResolveDependencies(candidates.First(), authenticated, candidatePackageDefinitions); } }