Пример #1
0
        public static void RetrievePaketBootstrapper(this ICakeContext context, DirectoryPath paketDirectory, string githubOAuthToken)
        {
            var urlPartHelper = new GitHubUrlPathParts
            {
                Base = GithubUrlPath
            };

            var urlHelper        = new GitHubApiUrlHelper(urlPartHelper);
            var retrieverLog     = new CakeRetrieverLog(context.Log);
            var releaseRetriever = new GitHubReleaseRetriever(urlHelper, retrieverLog, githubOAuthToken);

            paketDirectory.CheckAndCreateDirectory(context.Log);
            if (File.Exists(Path.Combine(paketDirectory.FullPath, PaketAsset)))
            {
                context.Log.Information("Paket Bootstrapper already exists - skipping download");
                return;
            }

            var latestUrl = releaseRetriever.GetLatestReleaseUrlAsync(PaketOwner, PaketRepo, PaketAsset).Result;

            if (string.IsNullOrEmpty(latestUrl))
            {
                context.Log.Error("Failed to retrieve link for latest Paket BootStrapper");
                throw new CakeException("Failed to retrieve link for latest Paket Bootstrapper");
            }

            var result = releaseRetriever.DownloadFileAsync(latestUrl, paketDirectory.FullPath, PaketAsset).Result;

            if (!result)
            {
                context.Log.Error("An error occured while trying to retrieve the Paket Bootstrapper");
                throw new CakeException("Error occured while trying to retrieve the Paket Bootstrapper");
            }

            context.Log.Information("Completed retrieval of the Paket Bootstrapper");
        }