Exemplo n.º 1
0
        /// <summary>
        /// Downloads a KRE
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="folder"></param>
        /// <returns><c>true</c> if not already downloaded, otherwise <c>false</c>.</returns>
        static async Task <bool> Download(string fullName, string folder)
        {
            const string URL = "https://www.myget.org/F/aspnetvnext/api/v2/package/{0}/{1}";

            var runtime = KRuntime.Parse(fullName);

            var parts = new[] {
                runtime.PackageName,
                runtime.Version
            };

            var url  = String.Format(CultureInfo.InvariantCulture, URL, parts);
            var file = Path.Combine(folder, fullName + ".nupkg");

            if (Directory.Exists(folder))
            {
                return(false);
            }

            Directory.CreateDirectory(folder);

            using (var client = new WebClient())
            {
                client.Credentials = credentials;
                await client.DownloadFileTaskAsync(url, file);
            }

            await Unpack(file, folder);

            return(true);
        }
Exemplo n.º 2
0
        static IEnumerable <KRuntime> ListParts(string packagesFolder)
        {
            foreach (var path in new DirectoryInfo(packagesFolder).EnumerateDirectories("KRE-*", SearchOption.TopDirectoryOnly))
            {
                if (!Directory.Exists(Path.Combine(path.FullName, "bin")))
                {
                    continue;
                }

                var active = false;
                var PATH   = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User);
                foreach (var portion in PATH.Split(';'))
                {
                    if (portion.StartsWith(path.FullName, StringComparison.OrdinalIgnoreCase))
                    {
                        active = true;
                    }
                }

                yield return(KRuntime.Parse(path.Name, path.FullName, active));
                //var parts1 = path.Name.Split(new[] { '.' }, 2);
                //var parts2 = parts1[0].Split(new[] { '-' }, 3);
                //yield return new KRuntime(
                //    active: active,
                //    version: parts1[1],
                //    runtime: parts2[1],
                //    architecture: parts2[2],
                //    location: path.FullName);
            }
        }
Exemplo n.º 3
0
        static string VersionOrAlias(string versionOrAlias, string platform = defaultPlatform, string architecture = defaultArchitecture)
        {
            string version;

            if (File.Exists(Path.Combine(userKreAlias, versionOrAlias + ".txt")))
            {
                var runtime = KRuntime.Parse(AliasGet(versionOrAlias));
                version      = runtime.Version;
                platform     = runtime.Runtime ?? platform;
                architecture = runtime.Architecture ?? architecture;
            }
            else
            {
                version = versionOrAlias;
            }

            return("KRE-" + platform + "-" + architecture + "-" + version);
        }