示例#1
0
        private static void InstallPackage(IReadOnlyList <string> packages, bool quiet = false)
        {
            List <string> toInstall = new List <string>();

            foreach (string package in packages)
            {
                if (package.Exists())
                {
                    TemplateCache.Scan(package);
                }
                else
                {
                    toInstall.Add(package);
                }
            }

            NuGetUtil.InstallPackage(toInstall, quiet);

            TemplateCache.WriteTemplateCaches();

            if (!quiet)
            {
                ListTemplates(new CommandArgument());
            }
        }
示例#2
0
        private static void InstallPackage(IReadOnlyList <string> packages, bool installingTemplates, bool global, bool quiet = false)
        {
            NuGetUtil.InstallPackage(packages, installingTemplates, global, quiet, TryAddSource);
            Broker.ComponentRegistry.ForceReinitialize();

            if (!quiet)
            {
                ListTemplates(new CommandArgument(), new CommandOption("--notReal", CommandOptionType.SingleValue));
            }
        }
        public async Task <bool> CheckForUpdatesAsync(string location)
        {
            if (Path.GetExtension(location).ToUpperInvariant() == ".NUPKG")
            {
                using (IDisposable <ITemplateSourceFolder> root = RootFor(location))
                {
                    ITemplateSourceFile nuspec = root.Value.EnumerateFiles("*.nuspec", SearchOption.TopDirectoryOnly).FirstOrDefault();

                    if (nuspec != null)
                    {
                        string id, version;
                        GetPackageIdAndVersion(nuspec, out id, out version);

                        NuGetUtil.Init();
                        string newerVersion = await NuGetUtil.GetCurrentVersionOfPackageAsync(id, version);

                        return(newerVersion != null);
                    }
                }
            }

            return(false);
        }