public override bool Execute(PublishInput input) { var report = new PublishReport(); input.EachSolution(solution => { RippleLog.Info("Building nuget files for " + solution.Name); var artifactDirectory = solution.Directory.AppendPath(input.ArtifactsFlag); RippleLog.Info("Cleaning out any existing nuget files before continuing"); new FileSystem().CleanDirectory(artifactDirectory); solution.Specifications.Each(nuget => { RippleLog.Info("Creating and publishing Nuget for " + nuget.Name); var packageFile = solution.Package(new PackageParams(nuget, SemanticVersion.Parse(input.Version), artifactDirectory, input.CreateSymbolsFlag)); var detail = solution.Publisher.PublishPackage(input.ServerFlag, packageFile, input.ApiKey); report.Add(detail); }); }); RippleLog.InfoMessage(report); if (!report.IsSuccessful()) { RippleAssert.Fail("Failure publishing packages"); } return(true); }
public override bool Execute(FindNugetsInput input) { var solution = Solution.For(input); var feeds = FeedRegistry.FeedsFor(solution); var results = feeds.SelectMany(feed => { return(feed .FindAllLatestByName(input.Nuget) .Select(nuget => new SearchResult { Nuget = nuget, Provenance = feed.Repository })); }); results .OrderBy(x => x.Nuget.Name) .ThenBy(x => x.Nuget.Version) .Each(result => { RippleLog.Info("{0}, {1} ({2})".ToFormat(result.Nuget.Name, result.Nuget.Version, result.Provenance.Source)); }); return(true); }
public ReferenceStatus AddReference(string name, string hintPath) { if (hintPath.IsNotEmpty()) { hintPath = hintPath.Trim(); } Reference reference = FindReference(name); if (reference == null) { reference = new Reference { Name = name }; _references.Value.Add(reference); } string 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.Info("HintPath changed: " + original + " to " + hintPath); } return(status); }
public override bool Execute(BatchPublishInput input) { RippleLog.Info("Looking for *.nupkg files in " + input.Directory); var files = new FileSystem() .FindFiles(input.Directory, new FileSet { Include = "*.nupkg" }) .ToArray(); _index = 0; _count = files.Count(); var publisher = PublishingService.Basic(); var report = new PublishReport(); files.Each(file => { _index++; RippleLog.Info("Trying to publish {0}, {1} or {2}".ToFormat(file, _index, _count)); var detail = publisher.PublishPackage(input.ServerFlag, file, input.ApiKeyFlag); report.Add(detail); }); RippleLog.InfoMessage(report); if (!report.IsSuccessful()) { RippleAssert.Fail("Failure publishing packages"); } return(true); }
public IPackage ExplodeTo(string directory) { var explodedDirectory = ExplodedDirectory(directory); RippleLog.Info("Exploding to " + explodedDirectory); var fileSystem = new FileSystem(); fileSystem.CreateDirectory(explodedDirectory); fileSystem.ForceClean(explodedDirectory); var package = new ZipPackage(_path); package.GetFiles().Each(file => { var target = explodedDirectory.AppendPath(file.Path); fileSystem.CreateDirectory(target.ParentDirectory()); using (var stream = new FileStream(target, FileMode.Create, FileAccess.Write)) { file.GetStream().CopyTo(stream); } }); fileSystem.CopyToDirectory(_path, explodedDirectory); fileSystem.DeleteFile(_path); var newFile = Path.Combine(explodedDirectory, Path.GetFileName(_path)); return(new ZipPackage(newFile)); }
public void CreateSymbolsPackage(PackageParams ctx) { var symbolsBuilder = symbolsPackageBuilderFor(ctx.Spec, ctx.Version); // remove unnecessary files when building the symbols package ExcludeFilesForSymbolPackage(symbolsBuilder.Files); if (!symbolsBuilder.Files.Any()) { RippleLog.Info("No symbols could be generated for {0} since no symbol files could be found. This is expected if this is a code only package".ToFormat(ctx.Spec.Name)); return; } var nupkgSymbolsFileName = Path.Combine(ctx.OutputPath, "{0}.{1}.symbols.nupkg".ToFormat(ctx.Spec.Name, ctx.Version)); var package = createPackage(symbolsBuilder, nupkgSymbolsFileName); var issues = package.Validate(Rules); if (issues.Any(x => x.Level == PackageIssueLevel.Error)) { Console.ForegroundColor = ConsoleColor.Red; issues.Each(issue => Console.WriteLine("[{0}] {1} - {2}", issue.Level, issue.Title, issue.Description)); Console.ResetColor(); RippleAssert.Fail("Symbols package failed validation"); } }
public void DownloadTo(string directory) { var file = directory.AppendPath(getFileName()); var client = new WebClient(); RippleLog.Info("Downloading {0} to {1}".ToFormat(Url, file)); client.DownloadFile(Url, file); }
public void PublishPackage(string file, string apiKey) { var packageServer = new PackageServer("https://nuget.org/", "ripple"); var package = new OptimizedZipPackage(file); RippleLog.Info("Publishing " + file + " with " + apiKey); packageServer.PushPackage(apiKey, package, (int)60.Minutes().TotalMilliseconds); }
public SolutionGraph ReadFrom(string folder) { folder = findCorrectFolder(folder); RippleLog.Info("Trying to read a Ripple SolutionGraph from " + folder); var solutions = readSolutions(folder); return(new SolutionGraph(solutions)); }
public override bool Execute(RemoveInput input) { RippleLog.Info("Trying to remove {0}".ToFormat(input.Nuget)); return(RippleOperation .For <RemoveInput>(input) .Step <RemoveNuget>() .ForceSave() .Execute()); }
public override bool Execute(CleanInput input) { input.EachSolution(solution => { RippleLog.Info("Cleaning Solution {0} at {1}".ToFormat(solution.Name, solution.Directory)); solution.Clean(input.ModeFlag); }); return(true); }
protected override void execute(CreatePackagesInput input, IRippleStepRunner runner) { new FileSystem().CreateDirectory(input.DestinationFlag); Solution.Specifications.Each(spec => { var version = input.VersionFlag; RippleLog.Info("Building the nuget spec file at " + spec.Filename + " as version " + version); Solution.Package(new PackageParams(spec, SemanticVersion.Parse(version), input.DestinationFlag, input.CreateSymbolsFlag)); ConsoleWriter.PrintHorizontalLine(); }); }
public void AssertIsValid() { var result = Validate(); if (result.IsValid()) { RippleLog.Info("Solution valid"); return; } ; RippleLog.InfoMessage(result); RippleAssert.Fail("Validation failed"); }
private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null) { var plan = new NugetPlan(); var target = request.Dependency; var solution = request.Solution; var key = target.Copy(); if (key.IsFloat()) { key = target.AsFloat(); } if (_planCache.Has(key)) { return(_planCache[key]); } _planCache.Fill(key, plan); RippleLog.Info("* Analyzing " + target); if (target.Version.IsEmpty()) { var remote = solution.FeedService.NugetFor(target); target.Version = remote.Version.ToString(); } if (request.UpdatesCurrentDependency()) { updateDependency(plan, request); } else if (!solution.Dependencies.Has(target.Name)) { plan.AddStep(new InstallSolutionDependency(target)); } projectInstallations(plan, parent, request); var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode); nugetDependencies.Each(x => { var childPlan = buildPlan(request.CopyFor(x), target); plan.Import(childPlan); }); return(plan); }
private void updateDependency(NugetPlan plan, NugetPlanRequest request) { var target = request.Dependency; var solution = request.Solution; var configured = solution.Dependencies.Find(target.Name); if (!request.ShouldUpdate(configured)) { RippleLog.Info("Warning: This operation requires {0} to be updated to {1} but it is marked as fixed. Use the force option to correct this.".ToFormat(target.Name, target.Version)); return; } plan.AddStep(new UpdateDependency(target)); }
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); } })); }
private void updateSpecification(CreatePackagesInput input, SpecGroup group, IEnumerable <SpecGroup> groups) { var spec = group.Spec; var local = Solution.LocalDependencies(); var nuspec = new NuspecDocument(spec.Filename); group .DetermineDependencies() .Each(dependency => { var localDependency = local.Get(dependency); var constraint = Solution.ConstraintFor(dependency); var version = constraint.SpecFor(localDependency.Version); var nuspecDep = new NuspecDependency(dependency.Name, version); RippleLog.Info("Adding dependency: " + nuspecDep); nuspec.AddDependency(nuspecDep); }); group .Projects .SelectMany(project => project.References) .Each(projectRef => { var target = groups.FirstOrDefault(x => x.Projects.Contains(projectRef)); if (target == null) { return; } // TODO -- Do we need another setting for project references? var constraint = Solution.NuspecSettings.Float; var version = constraint.SpecFor(new SemanticVersion(input.VersionFlag)); var nuspecDep = new NuspecDependency(target.Spec.Name, version); RippleLog.Info("Adding dependency: " + nuspecDep); nuspec.AddDependency(nuspecDep); }); nuspec.SaveChanges(); }
public IPackage ExplodeTo(string directory) { var explodedDirectory = directory.AppendPath(Name).ToFullPath(); RippleLog.Info("Exploding to " + explodedDirectory); var fileSystem = new FileSystem(); fileSystem.CreateDirectory(explodedDirectory); fileSystem.CleanDirectory(explodedDirectory); fileSystem.DeleteFile(FileName); fileSystem.WriteStringToFile(explodedDirectory.AppendPath(FileName), ""); return(new StubPackage(Name, Version.ToString())); }
public NuspecGenerationReport Execute(bool updateDependencies) { var rootPackagingDir = _solution.NugetSpecFolder.ParentDirectory(); var outputDir = rootPackagingDir.AppendPath(Guid.NewGuid().ToString()).ToFullPath(); var files = new FileSystem(); files.ForceClean(outputDir); files.CreateDirectory(outputDir); RippleLog.Info("Generating nuspec templates at: " + outputDir); var report = new NuspecGenerationReport(outputDir, updateDependencies); _plans.Each(plan => plan.Generate(report)); return(report); }
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()); } }
public override bool Execute(FindNugetsInput input) { var solution = Solution.For(input); var connectivity = new FeedConnectivity(); var feeds = connectivity.FeedsFor(solution); foreach (var feed in feeds) { connectivity.IfOnline(feed, f => { foreach (var nuget in f.FindLatestByName(input.Nuget)) { RippleLog.Info(string.Format("{0}, {1} ({2})", nuget.Name, nuget.Version, f.Repository.Source)); } }); } return(true); }
protected override void execute(CreatePackagesInput input, IRippleStepRunner runner) { runner.CreateDirectory(input.DestinationFlag); var report = runner.Get <NuspecGenerationReport>(); if (report == null) { throw new InvalidOperationException("Could not find generation report"); } report.NuspecFiles.Each(file => { var version = input.Version(); RippleLog.Info("Building the nuget spec file at " + file + " as version " + version); Solution.Package(new PackageParams(NugetSpec.ReadFrom(file), version, input.DestinationFlag, input.CreateSymbolsFlag)); RippleLog.Info(ConsoleWriter.HL); }); }
public override bool Execute(BatchPublishInput input) { Console.WriteLine("Looking for *.nupkg files in " + input.Directory); var files = new FileSystem().FindFiles(input.Directory, new FileSet { Include = "*.nupkg" }); _count = files.Count(); _index = 0; var publisher = PublishingService.For(SolutionMode.Ripple); files.Each(file => { _index++; RippleLog.Info("Trying to publish {0}, {1} or {2}".ToFormat(file, _index, _count)); publisher.PublishPackage(input.ServerFlag, file, input.ApiKeyFlag); }); return(true); }
public override bool Execute(LockInput input) { RippleLog.Info("Locking {0} at {1}".ToFormat(input.Name, input.Version)); input.EachSolution(solution => { var dependency = solution.FindDependency(input.Name); if (dependency == null) { solution.AddDependency(new Dependency(input.Name, input.Version, UpdateMode.Fixed)); } else { dependency.FixAt(input.Version); } solution.Save(); }); return(true); }
public INugetFile Get(string name) { try { var nuget = _dependencies.SingleOrDefault(x => x.Name.EqualsIgnoreCase(name)); if (nuget == null) { RippleLog.DebugMessage(this); throw new ArgumentOutOfRangeException("name", "Could not find " + name); } return(nuget); } catch (InvalidOperationException) { var dependencies = _dependencies.Where(x => x.Name.EqualsIgnoreCase(name)).Select(x => x.FileName).Join(","); RippleLog.Info("Found multiple copies of {0}: {1}".ToFormat(name, dependencies)); throw; } }
public override bool Execute(PublishInput input) { input.EachSolution(solution => { Console.WriteLine("Building nuget files for " + solution.Name); var artifactDirectory = solution.Directory.AppendPath(input.ArtifactsFlag); Console.WriteLine("Cleaning out any existing nuget files before continuing"); new FileSystem().CleanDirectory(artifactDirectory); solution.Specifications.Each(nuget => { RippleLog.Info("Creating and publishing Nuget for " + nuget.Name); var packageFile = solution.Package(new PackageParams(nuget, SemanticVersion.Parse(input.Version), artifactDirectory, input.CreateSymbolsFlag)); solution.Publisher.PublishPackage(input.ServerFlag, packageFile, input.ApiKey); }); }); return(true); }
public IEnumerable <NugetPlanRequest> Requests(Solution solution) { BatchOperation operation; if (FileFlag.IsNotEmpty()) { var file = Path.Combine(RippleFileSystem.CurrentDirectory(), FileFlag); RippleLog.Info("Detected {0}. Reading batch instructions.".ToFormat(FileFlag)); var contents = File.ReadAllText(file); operation = BatchOperation.Parse(solution, contents); After = () => File.Delete(file); } else { operation = readFromCommandLine(solution); } return(operation.Requests); }
public static SolutionFiles FromDirectory(string directory) { var rippleConfigs = new FileSet { Include = RippleDependencyStrategy.RippleDependenciesConfig, DeepSearch = true }; var isClassicMode = false; var configFiles = new FileSystem().FindFiles(directory, rippleConfigs); if (!configFiles.Any()) { isClassicMode = true; RippleLog.Info("Classic Mode Detected"); } var files = isClassicMode ? Classic() : Basic(); files.resetDirectories(directory); return(files); }
public IPublishReportItem PublishPackage(string serverUrl, string file, string apiKey) { var packageServer = new PackageServer(serverUrl, "ripple"); var package = new OptimizedZipPackage(file); RippleLog.Info("Publishing " + file + " with " + apiKey); try { var info = new FileInfo(file); packageServer.PushPackage(apiKey, package, info.Length, (int)60.Minutes().TotalMilliseconds); return(new PublishSuccessful(package)); } catch (Exception ex) { // TODO -- Hate this if (ex.Message.Contains("exists")) { return(new VersionAlreadyExists(package)); } return(new PublishFailure(package, ex)); } }
private IPackage createPackage(PackageBuilder builder, string outputPath) { bool isExistingPackage = File.Exists(outputPath); try { using (Stream stream = File.Create(outputPath)) { builder.Save(stream); } } catch (Exception exc) { if (!isExistingPackage && File.Exists(outputPath)) { File.Delete(outputPath); } RippleAssert.Fail("Error creating package: " + exc.Message); } RippleLog.Info("Created nuget at: " + outputPath); return(new OptimizedZipPackage(outputPath)); }