private static bool TryResolveFromPackagePath(IFileSystem fileSystem, CompilationLibrary library, string basePath, out IEnumerable <string> results) { var paths = new List <string>(); foreach (var assembly in library.Assemblies) { string fullName; if (!ResolverUtils.TryResolveAssemblyFile(fileSystem, basePath, assembly, out fullName)) { // if one of the files can't be found, skip this package path completely. // there are package paths that don't include all of the "ref" assemblies // (ex. ones created by 'dotnet store') results = null; return(false); } paths.Add(fullName); } results = paths; return(true); }
public bool TryResolveAssemblyPaths(CompilationLibrary library, List <string> assemblies) { var isProject = string.Equals(library.Type, "project", StringComparison.OrdinalIgnoreCase) || string.Equals(library.Type, "msbuildproject", StringComparison.OrdinalIgnoreCase); var isPackage = string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase); var isReferenceAssembly = string.Equals(library.Type, "referenceassembly", StringComparison.OrdinalIgnoreCase); if (!isProject && !isPackage && !isReferenceAssembly && !string.Equals(library.Type, "reference", StringComparison.OrdinalIgnoreCase)) { return(false); } var refsPath = Path.Combine(_basePath, RefsDirectoryName); var isPublished = _fileSystem.Directory.Exists(refsPath); // Resolving reference assemblies requires refs folder to exist if (isReferenceAssembly && !isPublished) { return(false); } var directories = new List <string>() { _basePath }; if (isPublished) { directories.Insert(0, refsPath); } // Only packages can come from shared runtime var sharedPath = _dependencyContextPaths.SharedRuntime; if (isPublished && isPackage && !string.IsNullOrEmpty(sharedPath)) { var sharedDirectory = Path.GetDirectoryName(sharedPath); var sharedRefs = Path.Combine(sharedDirectory, RefsDirectoryName); if (_fileSystem.Directory.Exists(sharedRefs)) { directories.Add(sharedRefs); } directories.Add(sharedDirectory); } var paths = new List <string>(); foreach (var assembly in library.Assemblies) { bool resolved = false; var assemblyFile = Path.GetFileName(assembly); foreach (var directory in directories) { string fullName; if (ResolverUtils.TryResolveAssemblyFile(_fileSystem, directory, assemblyFile, out fullName)) { paths.Add(fullName); resolved = true; break; } } if (!resolved) { return(false); } } // only modify the assemblies parameter if we've resolved all files assemblies?.AddRange(paths); return(true); }