コード例 #1
0
        private static RemoteTemplatesPackage ResolvePackageForVersion(RemoteTemplatesSourceConfig config, string version, TextWriter output)
        {
            Version v = new Version(version);

            if (v.Build != 0 || v.Revision != 0)
            {
                output.WriteCommandText($"WARN: Downloading main version for {v.Major}.{v.Minor}, ignoring the version parts build ({v.Build}) and revision ({v.Revision}).");
            }

            RemoteTemplatesPackage match = config.Versions.Where(p => p.Version.Major == v.Major && p.Version.Minor == v.Minor)
                                           .OrderByDescending(p => p.Date).FirstOrDefault();

            return(match);
        }
コード例 #2
0
        public static void DownloadContent(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error)
        {
            try
            {
                output.WriteCommandHeader($"Downloading templates content from environment {options.Env.ToString()} ({options.StorageAccount})");

                RemoteTemplatesSourceConfig config = GetConfigFromCdn(options.Env);

                RemoteTemplatesPackage package = null;
                if (options.Version != null)
                {
                    package = ResolvePackageForVersion(config, options.Version, output);
                }
                else
                {
                    package = config.Latest;
                }

                if (package != null)
                {
                    Fs.EnsureFolder(options.Destination);

                    var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], package.Name, options.Destination);
                    output.WriteLine();
                    output.WriteCommandText($"Successfully downloaded '{result}'");
                    output.WriteLine();
                }
                else
                {
                    output.WriteLine();
                    output.WriteCommandText($"Package not found for the version '{options.Version}'");
                    output.WriteLine();
                }
            }
            catch (Exception ex)
            {
                error.WriteException(ex, $"Unable to download the file content from the specified environment.");
            }
        }