public CachingAssemblyFinderDecorator(IAssemblyFinder innerFinder) { ArgumentUtility.CheckNotNull("innerFinder", innerFinder); _innerFinder = innerFinder; _resultCache = new Lazy <IReadOnlyCollection <Assembly> > ( () => _innerFinder.FindAssemblies().ToList().AsReadOnly(), LazyThreadSafetyMode.ExecutionAndPublication); }
public void Run(string inDirectory, string outDirectory, string targetFramework, string listFormat) { if (string.IsNullOrWhiteSpace(inDirectory)) { var userHomePath = GetUserHomePath(); if (string.IsNullOrWhiteSpace(userHomePath)) { throw new ArgumentException("Could not get user home path from environment variables. Please provide it via the 'in' option.", nameof(inDirectory)); } inDirectory = Path.Combine(userHomePath, ".nuget"); } if (string.IsNullOrWhiteSpace(targetFramework)) { targetFramework = DefaultTfm; } if (string.IsNullOrWhiteSpace(outDirectory)) { outDirectory = Directory.GetCurrentDirectory(); } if (string.IsNullOrWhiteSpace(listFormat)) { listFormat = DefaultAssemblyListWriter; } var assemblyListWriter = _assemblyListWriterFactory.Create(listFormat); if (assemblyListWriter == null) { throw new ArgumentException("Invalid output format value.", nameof(targetFramework)); } // find and filter assemblies var assemblyPaths = _assemblyFinder.FindAssemblies(inDirectory); assemblyPaths = _assemblyFilter.Filter(assemblyPaths, targetFramework); assemblyPaths = assemblyPaths.OrderBy(x => x).ToList(); // render and write to disk var listContents = assemblyListWriter.Write(assemblyPaths); var outputFileName = GetOutputFileName(outDirectory, assemblyListWriter.GetFileExtension()); File.WriteAllText(outputFileName, listContents); }
private IEnumerable <Assembly> GetAssemblies(bool excludeGlobalTypes) { var assemblies = _assemblyFinder.FindAssemblies(); return(assemblies.Where(assembly => !excludeGlobalTypes || !assembly.GlobalAssemblyCache)); }
private void LoadAssemblies() { assemblies.Clear(); assemblies.AddRange(assemblyFinder.FindAssemblies()); }