private LocalPackageInfo FindPackageImpl(string packageId, NuGetVersion version) { var installPath = PathResolver.GetInstallPath(packageId, version); lock (GetLockObj(installPath)) { return(GetPackage(packageId, version, installPath)); } }
public void InstallVsix(IPackage package) { if (package == null) { return; } var packageDirectory = PathResolver.GetInstallPath(package); InstallVsixFromPackageDirectory(packageDirectory); }
private async Task<PackageReaderBase> ExtractPackage( SourcePackageDependencyInfo packageInfo, NuGetFramework projectFramework, SourceCacheContext cacheContext, PackageExtractionContext packageExtractionContext, ILogger logger, CancellationToken token) { logger.LogInformation($"Installing package '{packageInfo.Id} {packageInfo.Version}'."); var downloadResource = await packageInfo.Source.GetResourceAsync<DownloadResource>(token); var downloadResult = await downloadResource.GetDownloadResourceResultAsync( packageInfo, new PackageDownloadContext(cacheContext), SettingsUtility.GetGlobalPackagesFolder(Settings), logger, token); var installPath = PathResolver.GetInstallPath(packageInfo); foreach (var plugin in PackageManagerPlugins) { var accepted = await plugin.OnPackageInstallingAsync(packageInfo, projectFramework, downloadResult.PackageReader, installPath); if (!accepted) return downloadResult.PackageReader; } await PackageExtractor.ExtractPackageAsync( downloadResult.PackageSource, downloadResult.PackageStream, PathResolver, packageExtractionContext, token); installPath = PathResolver.GetInstalledPath(packageInfo); foreach (var plugin in PackageManagerPlugins) { await plugin.OnPackageInstalledAsync(packageInfo, projectFramework, downloadResult.PackageReader, installPath); } return downloadResult.PackageReader; }
private List <LocalPackageInfo> GetPackages(string id) { var packages = new List <LocalPackageInfo>(); var packageIdRoot = PathResolver.GetVersionListPath(id); if (!Directory.Exists(packageIdRoot)) { return(packages); } foreach (var fullVersionDir in Directory.EnumerateDirectories(packageIdRoot)) { LocalPackageInfo package; if (!_packageCache.TryGetValue(fullVersionDir, out package)) { var versionPart = fullVersionDir.Substring(packageIdRoot.Length).TrimStart(Path.DirectorySeparatorChar); // Get the version part and parse it NuGetVersion version; if (!NuGetVersion.TryParse(versionPart, out version)) { continue; } var nupkgMetadataPath = PathResolver.GetNupkgMetadataPath(id, version); var hashPath = PathResolver.GetHashPath(id, version); var zipPath = PathResolver.GetPackageFilePath(id, version); var installPath = PathResolver.GetInstallPath(id, version); // The nupkg metadata file is written last. If this file does not exist then the package is // incomplete and should not be used. if (_packageFileCache.Sha512Exists(nupkgMetadataPath)) { package = CreateLocalPackageInfo(id, version, fullVersionDir, nupkgMetadataPath, zipPath); // Cache the package, if it is valid it will not change // for the life of this restore. // Locking is done at a higher level around the id _packageCache.TryAdd(fullVersionDir, package); } // if hash file exists and it's not a fallback folder then we generate nupkg metadata file else if (!_isFallbackFolder && _packageFileCache.Sha512Exists(hashPath)) { LocalFolderUtility.GenerateNupkgMetadataFile(zipPath, installPath, hashPath, nupkgMetadataPath); package = CreateLocalPackageInfo(id, version, fullVersionDir, nupkgMetadataPath, zipPath); // Cache the package, if it is valid it will not change // for the life of this restore. // Locking is done at a higher level around the id _packageCache.TryAdd(fullVersionDir, package); } } // Add the package if it is valid if (package != null) { packages.Add(package); } } return(packages); }