private void Initialize(CoreV2.NuGet.IFileSystem fileSystem, IConsole console) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; using (var catalog = new AggregateCatalog(new AssemblyCatalog(GetType().Assembly))) { if (!IgnoreExtensions) { AddExtensionsToCatalog(catalog, console); } try { using (var container = new CompositionContainer(catalog)) { container.ComposeExportedValue(console); container.ComposeExportedValue <CoreV2.NuGet.IPackageRepositoryFactory>(new CommandLineRepositoryFactory(console)); container.ComposeExportedValue(fileSystem); container.ComposeParts(this); } } catch (ReflectionTypeLoadException ex) when(ex?.LoaderExceptions.Length > 0) { throw new AggregateException(ex.LoaderExceptions); } } }
internal static void RemoveOldFile(CoreV2.NuGet.IFileSystem fileSystem) { var oldFile = typeof(Program).Assembly.Location + ".old"; try { if (fileSystem.FileExists(oldFile)) { fileSystem.DeleteFile(oldFile); } } catch { // We don't want to block the exe from usage if anything failed } }