private void DumpIndex(ILocalPackageIndexBuilder builder, string dumpFile) { if (File.Exists(dumpFile)) { File.Delete(dumpFile); } StringBuilder stringBuilder = new StringBuilder(); var allTypes = builder.Index.GetTypes().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Types,,,,"); foreach (var type in allTypes) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", type.PackageName, type.PackageVersion, type.AssemblyName, type.FullName, string.Join(";", type.TargetFrameworks))); } var allExtensions = builder.Index.GetExtensions().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Extensions,,,,"); foreach (var extension in allExtensions) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", extension.PackageName, extension.PackageVersion, extension.AssemblyName, extension.FullName, string.Join(";", extension.TargetFrameworks))); } var allNamespaces = builder.Index.GetNamespaces().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Namespaces,,,,"); foreach (var ns in allNamespaces) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", ns.PackageName, ns.PackageVersion, ns.AssemblyName, ns.Name, string.Join(";", ns.TargetFrameworks))); } File.WriteAllText(dumpFile, stringBuilder.ToString()); _consoleUI.WriteNormalLine(string.Format(Resources.DumpMessage, Path.GetFullPath(dumpFile))); }
private void ProcessAction(ILocalPackageIndexBuilder builder, Arguments arguments, bool commandMode) { LocalPackageIndexBuilderResult result = null; switch (arguments.Action) { case PackageIndexManagerAction.Build: result = builder.BuildAsync().Result; break; case PackageIndexManagerAction.Rebuild: result = builder.Rebuild(); break; case PackageIndexManagerAction.Clean: result = builder.Clean(); break; case PackageIndexManagerAction.Add: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.AddPackage(arguments.Package, arguments.Force); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToAdd); } break; case PackageIndexManagerAction.Remove: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.RemovePackage(arguments.Package); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToRemove); } break; case PackageIndexManagerAction.Query: if (!string.IsNullOrEmpty(arguments.Type)) { DoQuery(() => { return(builder.Index.GetTypes(arguments.Type).Select(x => (object)x).ToList()); }); } else if (!string.IsNullOrEmpty(arguments.Package)) { DoQuery(() => { return(builder.Index.GetPackages(arguments.Package).Select(x => (object)x).ToList()); }); } else { _consoleUI.WriteNormalLine(Resources.PackageOrTypeIsMissing); } break; default: _consoleUI.WriteNormalLine(Resources.ActionUnrecognized); return; } if (result != null) { _consoleUI.WriteHighlitedLine(string.Format(Resources.TimeElapsed, result.TimeElapsed)); _consoleUI.WriteNormalLine(string.Empty); } }
private void ProcessAction(ILocalPackageIndexBuilder builder, Arguments arguments, bool commandMode) { LocalPackageIndexBuilderResult result = null; switch (arguments.Action) { case PackageIndexManagerAction.Build: result = builder.BuildAsync(shouldClean: false, newOnly: false, cancellationToken: CancellationToken.None).Result; break; case PackageIndexManagerAction.Rebuild: result = builder.Rebuild(); break; case PackageIndexManagerAction.Clean: result = builder.Clean(); break; case PackageIndexManagerAction.Add: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.AddPackage(arguments.Package, arguments.Force); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToAdd); } break; case PackageIndexManagerAction.Remove: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.RemovePackage(packageName: arguments.Package, force: false); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToRemove); } break; case PackageIndexManagerAction.Query: if (!string.IsNullOrEmpty(arguments.Type)) { DoQuery(() => { return(builder.Index.GetTypes(arguments.Type).Select(x => (object)x).ToList()); }); } else if (!string.IsNullOrEmpty(arguments.Package)) { DoQuery(() => { return(builder.Index.GetPackages(arguments.Package).Select(x => (object)x).ToList()); }); } else if (!string.IsNullOrEmpty(arguments.Namespace)) { DoQuery(() => { return(builder.Index.GetNamespaces(arguments.Namespace).Select(x => (object)x).ToList()); }); } else if (!string.IsNullOrEmpty(arguments.Extension)) { DoQuery(() => { return(builder.Index.GetExtensions(arguments.Extension).Select(x => (object)x).ToList()); }); } else { _consoleUI.WriteNormalLine(Resources.PackageOrTypeIsMissing); } break; case PackageIndexManagerAction.Dump: var dumpFile = arguments.DumpFile; if (string.IsNullOrEmpty(dumpFile)) { dumpFile = "IndexDump.csv"; } DumpIndex(builder, dumpFile); break; default: _consoleUI.WriteNormalLine(Resources.ActionUnrecognized); return; } if (result != null) { _consoleUI.WriteHighlitedLine(string.Format(Resources.TimeElapsed, result.TimeElapsed)); _consoleUI.WriteNormalLine(string.Empty); } }
private LocalNugetPackageIndex() { _indexFactory = new PackageIndexFactory(); _indexBuilder = _indexFactory.GetLocalIndexBuilder(createIfNotExists: false); }
private LocalNugetPackageIndex() { _indexFactory = new PackageIndexFactory(); _indexBuilder = _indexFactory.GetLocalIndexBuilder(createIfNotExists: false); }
private void ProcessAction(ILocalPackageIndexBuilder builder, Arguments arguments, bool commandMode) { LocalPackageIndexBuilderResult result = null; switch (arguments.Action) { case PackageIndexManagerAction.Build: result = builder.BuildAsync(shouldClean:false, newOnly: false, cancellationToken: CancellationToken.None).Result; break; case PackageIndexManagerAction.Rebuild: result = builder.Rebuild(); break; case PackageIndexManagerAction.Clean: result = builder.Clean(); break; case PackageIndexManagerAction.Add: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.AddPackage(arguments.Package, arguments.Force); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToAdd); } break; case PackageIndexManagerAction.Remove: if (!string.IsNullOrEmpty(arguments.Package)) { result = builder.RemovePackage(packageName:arguments.Package, force: false); } else { _consoleUI.WriteNormalLine(Resources.PackageIsMissingToRemove); } break; case PackageIndexManagerAction.Query: if (!string.IsNullOrEmpty(arguments.Type)) { DoQuery(() => { return builder.Index.GetTypes(arguments.Type).Select(x => (object)x).ToList(); }); } else if (!string.IsNullOrEmpty(arguments.Package)) { DoQuery(() => { return builder.Index.GetPackages(arguments.Package).Select(x => (object)x).ToList(); }); } else if (!string.IsNullOrEmpty(arguments.Namespace)) { DoQuery(() => { return builder.Index.GetNamespaces(arguments.Namespace).Select(x => (object)x).ToList(); }); } else if (!string.IsNullOrEmpty(arguments.Extension)) { DoQuery(() => { return builder.Index.GetExtensions(arguments.Extension).Select(x => (object)x).ToList(); }); } else { _consoleUI.WriteNormalLine(Resources.PackageOrTypeIsMissing); } break; case PackageIndexManagerAction.Dump: var dumpFile = arguments.DumpFile; if (string.IsNullOrEmpty(dumpFile)) { dumpFile = "IndexDump.csv"; } DumpIndex(builder, dumpFile); break; default: _consoleUI.WriteNormalLine(Resources.ActionUnrecognized); return; } if (result != null) { _consoleUI.WriteHighlitedLine(string.Format(Resources.TimeElapsed, result.TimeElapsed)); _consoleUI.WriteNormalLine(string.Empty); } }
private void DumpIndex(ILocalPackageIndexBuilder builder, string dumpFile) { if (File.Exists(dumpFile)) { File.Delete(dumpFile); } StringBuilder stringBuilder = new StringBuilder(); var allTypes = builder.Index.GetTypes().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Types,,,,"); foreach (var type in allTypes) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", type.PackageName, type.PackageVersion, type.AssemblyName, type.FullName, string.Join(";", type.TargetFrameworks))); } var allExtensions = builder.Index.GetExtensions().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Extensions,,,,"); foreach (var extension in allExtensions) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", extension.PackageName, extension.PackageVersion, extension.AssemblyName, extension.FullName, string.Join(";", extension.TargetFrameworks))); } var allNamespaces = builder.Index.GetNamespaces().OrderBy(x => x.PackageName); stringBuilder.AppendLine("Namespaces,,,,"); foreach (var ns in allNamespaces) { stringBuilder.AppendLine(string.Format("{0},{1},{2},{3},{4}", ns.PackageName, ns.PackageVersion, ns.AssemblyName, ns.Name, string.Join(";", ns.TargetFrameworks))); } File.WriteAllText(dumpFile, stringBuilder.ToString()); _consoleUI.WriteNormalLine(string.Format(Resources.DumpMessage, Path.GetFullPath(dumpFile))); }