public ReferenceStatus AddReference(string name, string hintPath) { if (hintPath.IsNotEmpty()) { hintPath = hintPath.Trim(); } var reference = FindReference(name); if (reference == null) { reference = new AssemblyReference(name, hintPath); _project.Add(reference); } var original = reference.HintPath; reference.HintPath = hintPath; if (original.IsNotEmpty()) { original = original.Trim(); } var status = string.Equals(original, hintPath, StringComparison.OrdinalIgnoreCase) ? ReferenceStatus.Unchanged : ReferenceStatus.Changed; if (status == ReferenceStatus.Changed) { RippleLog.Debug("HintPath changed: " + original + " to " + hintPath); _project.Remove(reference); _project.Add(reference); } return(status); }
private void fixProject(Project project) { project.Dependencies.Each(dep => { var package = _packages[dep.Name]; if (package == null) { RippleLog.Debug("Could not find the IPackage for " + dep.Name); return; } var assemblies = package.AssemblyReferences; if (assemblies == null) { return; } var explicitRefs = package.PackageAssemblyReferences; if (explicitRefs.Any()) { project.Proj.AddAssemblies(dep, explicitRefs, assemblies); return; } project.Proj.AddAssemblies(dep, assemblies); }); }
protected override IRemoteNuget findLatest(Dependency query) { RippleLog.Debug("Searching for {0} from {1}".ToFormat(query, _url)); var candidates = repository.Search(query.Name, query.DetermineStability(Stability) == NugetStability.Anything) .Where(x => query.Name == x.Id).OrderBy(x => x.Id).ToList(); return(candidates.LatestNuget(query.VersionSpec)); }
public void EachSolution(Action <Solution> configure) { var solutions = FindSolutions(); solutions.Each(solution => { RippleLog.Debug("Solution " + solution.Name); configure(solution); }); }
private static Task restore(Dependency query, Solution solution, List <INugetFile> nugets) { return(Task.Factory.StartNew(() => { var nuget = solution.Restore(query); RippleLog.Debug("Downloading " + nuget); nugets.Add(nuget.DownloadTo(solution, solution.PackagesDirectory())); })); }
protected override IRemoteNuget find(Dependency query) { RippleLog.Debug("Searching for {0} in {1}".ToFormat(query, _directory)); SemanticVersion version; if (!SemanticVersion.TryParse(query.Version, out version)) { RippleLog.Debug("Could not find exact for " + query); return(null); } return(findMatching(nuget => query.MatchesName(nuget.Name) && nuget.Version == version)); }
public static string BranchUrl(Feed feed) { var branchUrl = feed.Url; if (branchUrl.Contains(BranchPlaceholder)) { var branchName = BranchDetector.Current(); branchUrl = branchUrl.Replace(BranchPlaceholder, branchName); RippleLog.Debug("Detected branch feed: {0}. Current branch is {1}. Setting url to {2}".ToFormat(feed, branchName, branchUrl), false); } return(branchUrl); }
private IEnumerable <IRemoteNuget> loadLatestFeed(int page) { var toSkip = (page - 1) * 100; var url = Url + FindAllLatestCommand.ToFormat(toSkip); RippleLog.Debug("Retrieving latest from " + url); var client = new WebClient(); var text = client.DownloadString(url); var document = new XmlDocument(); document.LoadXml(text); return(new NugetXmlFeed(document).ReadAll(this).ToArray()); }
private static Task restore(Dependency query, Solution solution, List <INugetFile> nugets) { return(Task.Factory.StartNew(() => { var nuget = solution.Restore(query); RippleLog.Debug("Downloading " + nuget); nugets.Add(nuget.DownloadTo(solution, solution.PackagesDirectory())); }).ContinueWith(task => { if (task.Exception == null) { RippleLog.Info("Downloaded " + query); } })); }
protected override IRemoteNuget findLatest(Dependency query) { RippleLog.Debug("Searching for {0} from {1}".ToFormat(query, _url)); var candidates = _repository.Search(query.Name, query.DetermineStability(_stability) == NugetStability.Anything) .Where(x => query.Name == x.Id).OrderBy(x => x.Id).ToList(); var candidate = candidates.FirstOrDefault(x => x.IsAbsoluteLatestVersion) ?? candidates.FirstOrDefault(x => x.IsLatestVersion); if (candidate == null) { return(null); } return(new RemoteNuget(candidate)); }
public void Execute(RippleInput input, IRippleStepRunner runner) { var missing = runner.Get <DownloadedNugets>(); if (missing.Any()) { Solution.AssertNoLockedFiles(); } missing.Each(nuget => { var dir = Solution.PackagesDirectory(); RippleLog.Debug("Exploding " + nuget.ToString()); nuget.ExplodeTo(dir); }); }
private IEnumerable <Dependency> findDependenciesFor(Dependency dependency, UpdateMode mode, int depth, SearchLocation location) { IRemoteNuget nuget = null; if (location == SearchLocation.Local && _solution.HasLocalCopy(dependency.Name)) { try { // Try to hit the local zip and read it. Mostly for testing but it'll detect a corrupted local package as well nuget = _solution.LocalNuget(dependency.Name); nuget.Dependencies().ToList(); RippleLog.Debug(dependency.Name + " already installed"); } catch { nuget = null; } } if (nuget == null) { nuget = NugetFor(dependency); } var dependencies = new List <Dependency>(); if (depth != 0) { var dep = dependency; var markAsFixed = mode == UpdateMode.Fixed || !isFloated(dependency); if (dep.IsFloat() && markAsFixed) { dep = new Dependency(nuget.Name, nuget.Version, UpdateMode.Fixed); } dependencies.Add(dep); } nuget .Dependencies() .Each(x => dependencies.AddRange(findDependenciesFor(x, mode, depth + 1, location))); return(dependencies.OrderBy(x => x.Name)); }
private IEnumerable <IRemoteNuget> findLatest() { var nugets = new List <INugetFile>(); RippleLog.Debug("Retrieving all latest from " + Directory); files .GroupBy(x => x.Name) .Each(x => { var latest = x.OrderByDescending(n => n.Version).First(); nugets.Add(latest); }); return(nugets .Select(x => new FileSystemNuget(x)) .OrderBy(x => x.Name)); }
private INugetFeed buildFileSystemFeed(Feed feed) { var directory = feed.Url.Replace("file://", ""); if (directory.Contains(BranchPlaceholder)) { var branchName = BranchDetector.Current(); directory = directory.Replace(BranchPlaceholder, branchName); RippleLog.Debug("Detected branch feed: {0}. Current branch is {1}. Setting directory to {2}".ToFormat(feed, branchName, directory)); } if (feed.Mode == UpdateMode.Fixed) { return(new FileSystemNugetFeed(directory, feed.Stability)); } return(new FloatingFileSystemNugetFeed(directory, feed.Stability)); }
protected override IRemoteNuget findLatest(Dependency query) { RippleLog.Debug("Searching for latest of {0} in {1}".ToFormat(query, _directory)); var nugets = files .Where(x => query.MatchesName(x.Name) && (!x.IsPreRelease || (x.IsPreRelease && query.DetermineStability(_stability) == NugetStability.Anything))) .ToList(); var nuget = nugets .OrderByDescending(x => x.Version) .FirstOrDefault(); if (nuget == null) { return(null); } return(new FileSystemNuget(nuget)); }
public void IfOnline(INugetFeed feed, Action <INugetFeed> continuation) { try { if (isOffline(feed)) { RippleLog.Debug("Feed offline. Ignoring " + feed); return; } continuation(feed); } catch (Exception exc) { MarkOffline(feed); RippleLog.Info("Feed unavailable: " + feed); RippleLog.Debug(exc.ToString()); } }
protected override IRemoteNuget find(Dependency query) { SemanticVersion version; if (!SemanticVersion.TryParse(query.Version, out version)) { RippleLog.Debug("Could not find exact for " + query); return(null); } var versionSpec = new VersionSpec(version); var package = _repository.FindPackages(query.Name, versionSpec, query.DetermineStability(_stability) == NugetStability.Anything, true).SingleOrDefault(); if (package == null) { return(null); } return(new RemoteNuget(package)); }
private void fixProject(Project project) { project.Dependencies.Each(dep => { var package = _packages[dep.Name]; if (package == null) { RippleLog.Debug("Could not find the IPackage for " + dep.Name); return; } var assemblies = package.AssemblyReferences; if (assemblies == null) { return; } project.CsProj.AddAssemblies(dep, assemblies, _solution); }); }
private static Task restore(Dependency query, Solution solution, MissingNugetReport report, List <INugetFile> nugets) { RippleLog.Debug("Restoring " + query); var result = solution.Restore(query); return(result.ContinueWith(task => { if (!task.Result.Found) { report.Add(query); report.AddProblems(task.Result.Problems); return; } var nuget = task.Result.Nuget; RippleLog.Debug("Downloading " + nuget); nugets.Add(nuget.DownloadTo(solution, solution.PackagesDirectory())); }, TaskContinuationOptions.NotOnFaulted)); }
private IEnumerable <IRemoteNuget> findLatest() { var nugets = new List <INugetFile>(); RippleLog.Debug("Retrieving all latest from " + Directory); var distinct = from nuget in files let name = nuget.Name.ToLower() group nuget by name; distinct .Each(x => { var latest = x.OrderByDescending(n => n.Version).First(); nugets.Add(latest); }); return(nugets .Select(x => new FileSystemNuget(x)) .OrderBy(x => x.Name)); }
public IRemoteNuget LatestFor(Solution solution, Dependency dependency, bool forced = false) { if (dependency.Mode == UpdateMode.Fixed && !forced) { return(null); } IRemoteNuget latest = null; var feeds = _connectivity.FeedsFor(solution); foreach (var feed in feeds) { try { IRemoteNuget nuget = null; _connectivity.IfOnline(feed, x => nuget = feed.FindLatest(dependency)); if (latest == null) { latest = nuget; } if (latest != null && nuget != null && latest.Version < nuget.Version) { latest = nuget; } } catch (Exception) { RippleLog.Debug("Error while finding latest " + dependency); } } if (isUpdate(latest, dependency)) { return(remoteOrCached(latest)); } return(null); }
private NugetResult findLocal(Dependency dependency, SearchLocation location) { var result = new NugetResult(); if (location == SearchLocation.Local && _solution.HasLocalCopy(dependency.Name)) { try { // Try to hit the local zip and read it. Mostly for testing but it'll detect a corrupted local package as well result.Nuget = _solution.LocalNuget(dependency.Name); result.Nuget.Dependencies().ToList(); RippleLog.Debug(dependency.Name + " already installed"); } catch { result.Nuget = null; } } return(result); }
private Task <NugetResult> fill(Solution solution, Dependency dependency, Task <NugetResult> result, LinkedListNode <INugetFinder> node) { var innerTask = result.ContinueWith(task => { NugetResult parent; if (task.IsFaulted) { parent = new NugetResult(); var problem = parent.AddProblem(task.Exception); RippleLog.Debug(problem.Message); if (problem.Exception != null) { RippleLog.Debug(problem.Exception.StackTrace); } } else { parent = task.Result; } if (!parent.Found && node.Next != null) { var finder = node.Next.Value; var inner = finder.Find(solution, dependency); parent.Import(inner); } return(parent); }, TaskContinuationOptions.AttachedToParent); if (node.Next != null) { return(fill(solution, dependency, innerTask, node.Next)); } return(innerTask); }
public void AddAssemblies(Dependency dep, IEnumerable <IPackageAssemblyReference> assemblies) { bool needsSaved = false; assemblies = findCompatibleItems(assemblies).ToList(); assemblies.Each(assem => { var assemblyName = Path.GetFileNameWithoutExtension(assem.Name); if (assemblyName == "_._" || assemblyName == "_") { return; } if (!_solution.ShouldAddReference(dep, assemblyName)) { return; } var nugetDir = _solution.NugetFolderFor(dep.Name); var assemblyPath = nugetDir.AppendPath(assem.Path); var hintPath = assemblyPath.PathRelativeTo(_filename.ParentDirectory()); if (AddReference(assemblyName, hintPath) == ReferenceStatus.Changed) { RippleLog.Debug("Updated reference for {0} to {1}".ToFormat(_filename, hintPath)); needsSaved = true; } }); if (needsSaved) { RippleLog.Debug("Writing changes to " + _filename); Write(); } }
private IEnumerable <Dependency> findDependenciesFor(Dependency dependency, UpdateMode mode, SearchLocation location) { var dependencies = new List <Dependency>(); var task = findDependenciesFor(dependency, mode, 0, location, dependencies); try { task.Wait(); if (!task.Result.Found) { RippleAssert.Fail("Could not find " + dependency.Name); } } catch (AggregateException ex) { var flat = ex.Flatten(); if (flat.InnerException != null) { RippleLog.Debug(flat.InnerException.Message); } } return(dependencies.OrderBy(x => x.Name)); }
private bool isOnline() { try { using (var client = new WebClient()) { ICredentials credentials; if (NugetCredentialsProvider.Instance.TryGetCredentials(_url, out credentials)) { client.Credentials = credentials; } using (var stream = client.OpenRead(_url)) { return(true); } } } catch (Exception exc) { RippleLog.Debug("Feed unvailable: {0}".ToFormat(_url)); RippleLog.Debug(exc.Message); return(false); } }