src/Microsoft.PackageManagement.NuGetProvider/NugetLightClient.cs
/// <summary>
/// Install a single package without checking for dependencies
/// </summary>
/// <param name="pkgItem"></param>
/// <param name="request"></param>
/// <param name="progressTracker"></param>
/// <returns></returns>
Install a single package without checking for dependencies
Install a single package without checking for dependencies
internal static bool InstallSinglePackage(PackageItem pkgItem, NuGetRequest request, ProgressTracker progressTracker)
        {
            PackageItem packageToBeInstalled;
            if (pkgItem == null || pkgItem.PackageSource == null || pkgItem.PackageSource.Repository == null)
            {
                return false;
            }
            if (Directory.Exists(pkgItem.PackageSource.Location))
            {
                var fileLocation = pkgItem.PackageSource.Repository.FindPackage(pkgItem.Id, new SemanticVersion(pkgItem.Version), request).FullFilePath;
                packageToBeInstalled = NuGetClient.InstallPackageLocal(pkgItem.Id, pkgItem.Version, request, pkgItem.PackageSource, fileLocation, progressTracker);
            }
            else
            {             
                string append = String.Format(CultureInfo.InvariantCulture, "/package/{0}/{1}", pkgItem.Id, pkgItem.Version);
                string httpquery = PathUtility.UriCombine(pkgItem.PackageSource.Repository.Source, append);
                packageToBeInstalled = NuGetClient.InstallPackage(pkgItem.Id, pkgItem.Version, request, pkgItem.PackageSource,
                    string.IsNullOrWhiteSpace(pkgItem.Package.ContentSrcUrl) ? httpquery : pkgItem.Package.ContentSrcUrl,
                    pkgItem.Package.PackageHash, pkgItem.Package.PackageHashAlgorithm, progressTracker);
            }
            if (packageToBeInstalled != null)
            {
                if (!pkgItem.PackageSource.Repository.IsFile)
                {
                    request.YieldPackage(pkgItem, packageToBeInstalled.PackageSource.Name, packageToBeInstalled.FullPath);
                }
                else
                {
                    request.YieldPackage(packageToBeInstalled, packageToBeInstalled.PackageSource.Name, packageToBeInstalled.FullPath);
                }
                request.Debug(Messages.DebugInfoReturnCall, "NuGetClient", "InstallSinglePackage");
                return true;
            }
            return false;
        }
internal static bool InstallSinglePackage ( PackageItem pkgItem , NuGetRequest request , ProgressTracker progressTracker ) { PackageItem packageToBeInstalled ; if ( pkgItem == null || pkgItem . PackageSource == null || pkgItem . PackageSource . Repository == null ) { return false ; } if ( Directory . Exists ( pkgItem . PackageSource . Location ) ) { var fileLocation = pkgItem . PackageSource . Repository . FindPackage ( pkgItem . Id , new SemanticVersion ( pkgItem . Version ) , request ) . FullFilePath ; packageToBeInstalled = NuGetClient . InstallPackageLocal ( pkgItem . Id , pkgItem . Version , request , pkgItem . PackageSource , fileLocation , progressTracker ) ; } else { string append = String . Format ( CultureInfo . InvariantCulture , " " , pkgItem . Id , pkgItem . Version ) ; string httpquery = PathUtility . UriCombine ( pkgItem . PackageSource . Repository . Source , append ) ; packageToBeInstalled = NuGetClient . InstallPackage ( pkgItem . Id , pkgItem . Version , request , pkgItem . PackageSource , string . IsNullOrWhiteSpace ( pkgItem . Package . ContentSrcUrl ) ? httpquery : pkgItem . Package . ContentSrcUrl , pkgItem . Package . PackageHash , pkgItem . Package . PackageHashAlgorithm , progressTracker ) ; } if ( packageToBeInstalled != null ) { if ( ! pkgItem . PackageSource . Repository . IsFile ) { request . YieldPackage ( pkgItem , packageToBeInstalled . PackageSource . Name , packageToBeInstalled . FullPath ) ; } else { request . YieldPackage ( packageToBeInstalled , packageToBeInstalled . PackageSource . Name , packageToBeInstalled . FullPath ) ; } request . Debug ( Messages . DebugInfoReturnCall , " " , " " ) ; return true ; } return false ; }
Install a single package without checking for dependencies
Install a single package without checking for dependencies
// If the source location exists as a directory then we try to get the file location and provide to the packagelocal //V2 download package protocol: //sample url: http://www.nuget.org/api/v2/package/jQuery/2.1.3 // wait for the result from installpackage // Package is installed successfully // if this is a http repository, return metadata from online
None
pkgItem
PackageItem
None
request
NuGetRequest
None
progressTracker
ProgressTracker
None