public static IInstallService Create(string extractPath) { var frameworks = new List <NuGetFramework>() { NuGetFramework.AnyFramework }; var frameworkFilter = new NuGetFrameworkFilter(frameworks); var packageFilter = new DependencyNuGetPackageFilter( new List <Args.Dependency>() { new Args.Dependency("GitExtensions.Plugins", null) }, frameworks ); var install = new NuGetInstallService( new NuGetSourceRepositoryFactory(), new DefaultLog(), extractPath, new NuGetPackageContentService(new DefaultLog()), new NuGetPackageVersionService( new NuGetPackageContentService(new DefaultLog()), new DefaultLog(), packageFilter, frameworkFilter ), packageFilter, frameworkFilter ); return(install); }
public static (ISearchService search, IPackageSourceCollection sources) Create(string configFilePath) { var frameworks = new List <NuGetFramework>() { NuGetFramework.AnyFramework }; var frameworkFilter = new NuGetFrameworkFilter(frameworks); var packageFilter = new DependencyNuGetPackageFilter( new DefaultLog(), new List <Args.Dependency>() { new Args.Dependency("GitExtensions.Extensibility", null) }, frameworks ); var search = new NuGetSearchService( new NuGetSourceRepositoryFactory(), new DefaultLog(), new NuGetPackageContentService(new DefaultLog()), new NuGetPackageVersionService( new NuGetPackageContentService(new DefaultLog()), new DefaultLog(), packageFilter, frameworkFilter ), new DependencyNuGetPackageFilter( new DefaultLog(), new List <Args.Dependency>() { new Args.Dependency("GitExtensions.Extensibility", "0.2.0") }, frameworks ) ); EnsureConfigDeleted(configFilePath); var sources = new NuGetPackageSourceCollection( new PackageSourceProvider(new Settings(Environment.CurrentDirectory, configFilePath)) ); sources.Remove(sources.All.First()); sources.Add().Name("Local").Uri(new Uri(Path.Combine(Environment.CurrentDirectory, @"..\..\..\..\..\data\NuGetFeed"), UriKind.Absolute)).Save(); Assert.IsTrue(Directory.Exists(sources.All.First().Uri.AbsolutePath)); return(search, sources); }
protected override void OnStartup(StartupEventArgs e) { MemoryLogSerializer = new MemoryLogSerializer(new DefaultLogFormatter()); LogFactory = new DefaultLogFactory("root") .AddConsole() .AddSerializer(MemoryLogSerializer); ILog log = LogFactory.Scope("Startup"); log.Debug($"Startup arguments: {Environment.NewLine}{String.Join(" ", e.Args)}"); log.Debug($"Current version: {VersionInfo.Version}"); Args = new Args(e.Args); ProcessService = new ProcessService(this, Args.ProcessNamesToKillBeforeChange ?? new string[0]); Navigator = new Navigator(this, this, this); BuildExceptionHandler(); if (!Directory.Exists(Args.Path)) { Navigator.Notify("Packages", "Missing argument '--path' - a target path to install packages to.", Navigator.MessageType.Error); Shutdown(); return; } base.OnStartup(e); PackageSources = new NuGetPackageSourceCollection(new PackageSourceProvider(new Settings(Args.Path))); IReadOnlyCollection <NuGetFramework> frameworks = ParseMonikers(Args.Monikers); NuGetSourceRepositoryFactory repositoryFactory = new NuGetSourceRepositoryFactory(); INuGetPackageFilter packageFilter = null; if (Args.Dependencies.Any()) { packageFilter = new DependencyNuGetPackageFilter(Args.Dependencies, frameworks); } NuGetPackageContent.IFrameworkFilter frameworkFilter = null; if (Args.Monikers.Any()) { frameworkFilter = new NuGetFrameworkFilter(frameworks); } var selfPackageConfiguration = new SelfPackageConfiguration(Args.SelfPackageId); SelfPackageConverter.Configuration = selfPackageConfiguration; var contentService = new NuGetPackageContentService(log, frameworkFilter); var versionService = new NuGetPackageVersionService(contentService, log, packageFilter, frameworkFilter); var searchService = new NuGetSearchService(repositoryFactory, LogFactory.Scope("Search"), contentService, versionService, packageFilter, frameworkFilter); var installService = new NuGetInstallService(repositoryFactory, LogFactory.Scope("Install"), Args.Path, contentService, versionService, packageFilter, frameworkFilter); var selfUpdateService = new SelfUpdateService(this, ProcessService); EnsureSelfPackageInstalled(installService); var viewModel = new MainViewModel( PackageSources, searchService, installService, selfPackageConfiguration, selfUpdateService, NuGetPackageVersionComparer.Instance ); var wnd = new MainWindow(viewModel, ProcessService, Navigator); wnd.Show(); if (Args.IsSelfUpdate) { RunSelfUpdate(wnd); } }