public static CopyError Run(ProjectData data) { var copyError = new CopyError() { error = false, messages = new List <CopyError.Error>() }; foreach (var project in data.projects.Values) { var toCopy = new PackageSet(); addPackagesAndDependacies(copyError, toCopy, project.Dependencies, data.packages); foreach (var package in toCopy) { try { copy(project, package); } catch (Exception e) { copyError.AddError(e); } } } return(copyError); }
private static void addPackagesAndDependacies(CopyError copyError, PackageSet set, StringSet packageNames, PackageList all) { foreach (var packageName in packageNames) { Package package; if (all.TryGetValue(packageName, out package)) { set.Add(package); addPackagesAndDependacies(copyError, set, package.Dependencies, all); } else { copyError.AddError(new CopyError.Error { title = "Package not found!", message = string.Format("Could not find package with name '{0}'", packageName), }); } } }