public bool DownloadPackage(PublicObjectView packageView, string destination, RequestWrapper request) { try { request.Debug(Messages.DebugInfoCallMethod3, "NuGetLocalPackageFeed", "DownloadPackage", destination); PackageItem package = packageView.GetValue <PackageItem>(); // TODO: For now this has to require NuGetRequest, due to its usage of stuff like request.GetOptionValue and request.YieldPackage return(NuGetClient.InstallOrDownloadPackageHelper(package, request.Request, Constants.Install, (packageItem, progressTracker) => NuGetClient.DownloadSinglePackage(packageItem, request.Request, destination, progressTracker))); } finally { request.Debug(Messages.DebugInfoReturnCall, "NuGetLocalPackageFeed", "DownloadPackage"); } }
public bool InstallPackage(PublicObjectView packageView, RequestWrapper request) { try { request.Debug(Messages.DebugInfoCallMethod, "NuGetFilesFeed3", "InstallPackage"); PackageItem package = packageView.GetValue <PackageItem>(); request.Debug(Messages.DebugInfoCallMethod3, "NuGetFilesFeed3", "InstallPackage", package.FastPath); return(NuGetClient.InstallOrDownloadPackageHelper(package, request.Request, Constants.Install, (packageItem, progressTracker) => this.InstallSinglePackage(packageItem, request.Request, progressTracker))); } finally { request.Debug(Messages.DebugInfoReturnCall, "NuGetFilesFeed3", "InstallPackage"); } }
/// <summary> /// Installs a given package. /// </summary> /// <param name="fastPackageReference">A provider supplied identifier that specifies an exact package</param> /// <param name="request">An object passed in from the PackageManagement that contains functions that can be used to interact with its Provider</param> public void InstallPackage(string fastPackageReference, NuGetRequest request) { if (request == null) { throw new ArgumentNullException("request"); } request.Debug(Resources.Messages.DebugInfoCallMethod3, PackageProviderName, "InstallPackage", fastPackageReference); try { var pkgItem = request.GetPackageByFastpath(fastPackageReference); if (pkgItem == null) { request.WriteError(ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage); return; } if ((pkgItem.PackageSource == null) || (pkgItem.PackageSource.Location == null) || (pkgItem.Package == null)) { request.Debug(Resources.Messages.VariableCheck, "PackageSource or PackageSource.Location or Package object", "null"); request.WriteError(ErrorCategory.ObjectNotFound, fastPackageReference, Constants.Messages.UnableToResolvePackage, pkgItem.Id); return; } request.Debug(Resources.Messages.VariableCheck, "Package version", pkgItem.Version); request.Debug(Resources.Messages.VariableCheck, "Request's Destination", request.Destination); // got this far, let's install the package we came here for. if (!NuGetClient.InstallOrDownloadPackageHelper(pkgItem, request, Constants.Install, (packageItem, progressTracker) => NuGetClient.InstallSinglePackage(packageItem, request, progressTracker))) { // package itself didn't install. Write error request.WriteError(ErrorCategory.InvalidResult, pkgItem.Id, Constants.Messages.PackageFailedInstallOrDownload, pkgItem.Id, CultureInfo.CurrentCulture.TextInfo.ToLower(Constants.Install)); return; } } catch (Exception ex) { ex.Dump(request); request.WriteError(ErrorCategory.InvalidOperation, fastPackageReference, ex.Message); } }
/// <summary> /// Downloads a remote package file to a local location. /// </summary> /// <param name="fastPackageReference"></param> /// <param name="destLocation"></param> /// <param name="request">An object passed in from the PackageManagement that contains functions that can be used to interact with its Provider</param> public void DownloadPackage(string fastPackageReference, string destLocation, NuGetRequest request) { if (request == null) { throw new ArgumentNullException("request"); } request.Debug(Resources.Messages.DebugInfoCallMethod3, PackageProviderName, fastPackageReference, destLocation); try { var pkgItem = request.GetPackageByFastpath(fastPackageReference); if (pkgItem == null) { request.WriteError(ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage); return; } NuGetClient.InstallOrDownloadPackageHelper(pkgItem, request, Constants.Download, (packageItem, progressTracker) => NuGetClient.DownloadSinglePackage(packageItem, request, destLocation, progressTracker)); } catch (Exception ex) { ex.Dump(request); request.WriteError(ErrorCategory.InvalidOperation, fastPackageReference, ex.Message); } }