Exemple #1
0
        private string GetPackPath(string [] dotnetRootPaths, WorkloadPackId packageId, string packageVersion, WorkloadPackKind kind)
        {
            string packPath = "";
            bool   isFile;

            foreach (var rootPath in dotnetRootPaths)
            {
                switch (kind)
                {
                case WorkloadPackKind.Framework:
                case WorkloadPackKind.Sdk:
                    packPath = Path.Combine(rootPath, "packs", packageId.ToString(), packageVersion);
                    isFile   = false;
                    break;

                case WorkloadPackKind.Template:
                    packPath = Path.Combine(rootPath, "template-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg");
                    isFile   = true;
                    break;

                case WorkloadPackKind.Library:
                    packPath = Path.Combine(rootPath, "library-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg");
                    isFile   = true;
                    break;

                case WorkloadPackKind.Tool:
                    packPath = Path.Combine(rootPath, "tool-packs", packageId.ToString(), packageVersion);
                    isFile   = false;
                    break;

                default:
                    throw new ArgumentException($"The package kind '{kind}' is not known", nameof(kind));
                }

                bool packFound = isFile ?
                                 _fileExistOverride?.Invoke(packPath) ?? File.Exists(packPath) :
                                 _directoryExistOverride?.Invoke(packPath) ?? Directory.Exists(packPath);;

                if (packFound)
                {
                    break;
                }
            }
            return(packPath);
        }
Exemple #2
0
        private static string GetPackPath(string dotnetRootPath, WorkloadPackId packageId, string packageVersion, WorkloadPackKind kind)
        {
            switch (kind)
            {
            case WorkloadPackKind.Framework:
            case WorkloadPackKind.Sdk:
                return(Path.Combine(dotnetRootPath, "packs", packageId.ToString(), packageVersion));

            case WorkloadPackKind.Template:
                return(Path.Combine(dotnetRootPath, "template-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"));

            case WorkloadPackKind.Library:
                return(Path.Combine(dotnetRootPath, "library-packs", packageId.GetNuGetCanonicalId() + "." + packageVersion.ToLowerInvariant() + ".nupkg"));

            case WorkloadPackKind.Tool:
                return(Path.Combine(dotnetRootPath, "tool-packs", packageId.ToString(), packageVersion));

            default:
                throw new ArgumentException($"The package kind '{kind}' is not known", nameof(kind));
            }
        }