コード例 #1
0
 private static bool TryGetMatchingRestoredCommand(
     RestoredCommandIdentifier restoredCommandIdentifier,
     DirectoryPath nuGetGlobalPackagesFolder,
     CacheRow[] cacheTable,
     out RestoredCommand restoredCommandList)
 {
     (RestoredCommandIdentifier restoredCommandIdentifier, RestoredCommand restoredCommand)[]
コード例 #2
0
        public bool TryLoadHighestVersion(
            RestoredCommandIdentifierVersionRange query,
            DirectoryPath nuGetGlobalPackagesFolder,
            out RestoredCommand restoredCommandList)
        {
            restoredCommandList = null;
            string packageCacheFile = GetCacheFile(query.PackageId);

            if (_fileSystem.File.Exists(packageCacheFile))
            {
                var list = GetCacheTable(packageCacheFile)
                           .Select(c => Convert(query.PackageId, c, nuGetGlobalPackagesFolder))
                           .Where(strongTypeStored =>
                                  query.VersionRange.Satisfies(strongTypeStored.restoredCommandIdentifier.Version))
                           .Where(onlyVersionSatisfies =>
                                  onlyVersionSatisfies.restoredCommandIdentifier ==
                                  query.WithVersion(onlyVersionSatisfies.restoredCommandIdentifier.Version))
                           .OrderByDescending(allMatched => allMatched.restoredCommandIdentifier.Version)
                           .FirstOrDefault();

                if (!list.restoredCommand.Equals(default(RestoredCommand)))
                {
                    restoredCommandList = list.restoredCommand;
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
 private static CacheRow ConvertToCacheRow(
     RestoredCommandIdentifier restoredCommandIdentifier,
     RestoredCommand restoredCommandList)
 {
     return(new CacheRow
     {
         Version = restoredCommandIdentifier.Version.ToNormalizedString(),
         TargetFramework = restoredCommandIdentifier.TargetFramework.GetShortFolderName(),
         RuntimeIdentifier = restoredCommandIdentifier.RuntimeIdentifier.ToLowerInvariant(),
         Name = restoredCommandIdentifier.CommandName.Value,
         Runner = restoredCommandList.Runner,
         PathToExecutable = restoredCommandList.Executable.Value
     });
 }
コード例 #4
0
 private static CacheRow ConvertToCacheRow(
     RestoredCommandIdentifier restoredCommandIdentifier,
     RestoredCommand restoredCommandList,
     DirectoryPath nuGetGlobalPackagesFolder)
 {
     return(new CacheRow
     {
         Version = restoredCommandIdentifier.Version.ToNormalizedString(),
         TargetFramework = restoredCommandIdentifier.TargetFramework.GetShortFolderName(),
         RuntimeIdentifier = restoredCommandIdentifier.RuntimeIdentifier.ToLowerInvariant(),
         Name = restoredCommandIdentifier.CommandName.Value,
         Runner = restoredCommandList.Runner,
         RelativeToNuGetGlobalPackagesFolderPathToDll =
             Path.GetRelativePath(nuGetGlobalPackagesFolder.Value, restoredCommandList.Executable.Value)
     });
 }
コード例 #5
0
        public bool TryLoad(
            RestoredCommandIdentifier restoredCommandIdentifier,
            out RestoredCommand restoredCommand)
        {
            string packageCacheFile = GetCacheFile(restoredCommandIdentifier.PackageId);

            if (_fileSystem.File.Exists(packageCacheFile))
            {
                if (TryGetMatchingRestoredCommand(
                        restoredCommandIdentifier,
                        GetCacheTable(packageCacheFile),
                        out restoredCommand))
                {
                    return(true);
                }
            }

            restoredCommand = null;
            return(false);
        }
コード例 #6
0
        Convert(
            PackageId packageId,
            CacheRow cacheRow)
        {
            RestoredCommandIdentifier restoredCommandIdentifier =
                new RestoredCommandIdentifier(
                    packageId,
                    NuGetVersion.Parse(cacheRow.Version),
                    NuGetFramework.Parse(cacheRow.TargetFramework),
                    cacheRow.RuntimeIdentifier,
                    new ToolCommandName(cacheRow.Name));

            RestoredCommand restoredCommand =
                new RestoredCommand(
                    new ToolCommandName(cacheRow.Name),
                    cacheRow.Runner,
                    new FilePath(cacheRow.PathToExecutable));

            return(restoredCommandIdentifier, restoredCommand);
        }
コード例 #7
0
        Convert(
            PackageId packageId,
            CacheRow cacheRow,
            DirectoryPath nuGetGlobalPackagesFolder)
        {
            RestoredCommandIdentifier restoredCommandIdentifier =
                new RestoredCommandIdentifier(
                    packageId,
                    NuGetVersion.Parse(cacheRow.Version),
                    NuGetFramework.Parse(cacheRow.TargetFramework),
                    cacheRow.RuntimeIdentifier,
                    new ToolCommandName(cacheRow.Name));

            RestoredCommand restoredCommand =
                new RestoredCommand(
                    new ToolCommandName(cacheRow.Name),
                    cacheRow.Runner,
                    nuGetGlobalPackagesFolder
                    .WithFile(cacheRow.RelativeToNuGetGlobalPackagesFolderPathToDll));

            return(restoredCommandIdentifier, restoredCommand);
        }
コード例 #8
0
 private static bool TryGetMatchingRestoredCommand(
     RestoredCommandIdentifier restoredCommandIdentifier,
     CacheRow[] cacheTable,
     out RestoredCommand restoredCommandList)
 {
     (RestoredCommandIdentifier restoredCommandIdentifier, RestoredCommand restoredCommand)[]