Ejemplo n.º 1
0
    protected static NuGet.Commands.PublishCommand BuildPublishCommandFor(string source)
    {
        NuGet.IPackageSourceProvider sourceProvider = Substitute.For<NuGet.IPackageSourceProvider>();
            sourceProvider.LoadPackageSources().Returns(call => new List<NuGet.PackageSource> { new NuGet.PackageSource(source) });

            var cmd = new PublishCommand(sourceProvider);
            cmd.Console = Substitute.For<IConsole>();
            cmd.Source = source;

            return cmd;
    }
Ejemplo n.º 2
0
        private void PushPackage(string packagePath, string source, string apiKey) {
            var gallery = new GalleryServer(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            bool complete = false;
            gallery.ProgressAvailable += (sender, e) => {
                                             Console.Write("\r" + "Pushing: {0}", e.PercentComplete);

                                             if (e.PercentComplete == 100) {
                                                 Console.WriteLine();
                                                 complete = true;
                                             }
                                         };

            Console.WriteLine("Pushing {0} to {1}", package.GetFullName(), SourceProvider.GetDisplayName(source));

            try {
                using (Stream stream = package.GetStream()) {
                    gallery.CreatePackage(apiKey, stream);
                }
            }
            catch {
                if (!complete) {
                    Console.WriteLine();
                }
                throw;
            }

            // Publish the package on the server

            var cmd = new PublishCommand(SourceProvider);
            cmd.Console = Console;
            cmd.Source = source;
            cmd.Arguments = new List<string> {
                                                 package.Id,
                                                 package.Version.ToString(),
                                                 apiKey
                                             };
            cmd.Execute();
        }
Ejemplo n.º 3
0
        private void PushPackage(string packagePath, string source, string apiKey = null)
        {
            var gallery = new GalleryServer(source);

            // Use the specified api key or fall back to default behavior
            apiKey = apiKey ?? GetApiKey(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(source));

            using (Stream stream = package.GetStream()) {
                gallery.CreatePackage(apiKey, stream);
            }

            // Publish the package on the server
            if (!CreateOnly) {
                var cmd = new PublishCommand();
                cmd.Console = Console;
                cmd.Source = source;
                cmd.Arguments = new List<string> { package.Id, package.Version.ToString(), apiKey };
                cmd.Execute();
            }
            else {
                Console.WriteLine(NuGetResources.PushCommandPackageCreated, source);
            }
        }
Ejemplo n.º 4
0
        private void PushPackage(string packagePath, string source, string apiKey) {
            var packageServer = new PackageServer(source, "NuGet Command Line");

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            bool complete = false;

            //HACK no pretty source name, as they have made the call to  CommandLineUtility.GetSourceDisplayName(source) internal
            Console.WriteLine("Pushing {0} to {1}", package.GetFullName(), source);

            try {
                using (Stream stream = package.GetStream()) {
                    packageServer.PushPackage(apiKey, stream, 60000);
                }
            }
            catch {
                if (!complete) {
                    Console.WriteLine();
                }
                throw;
            }

            // Publish the package on the server

            var cmd = new PublishCommand();
            cmd.Console = Console;
            cmd.Source = source;
            cmd.Arguments.AddRange(new List<string> {
                                                 package.Id,
                                                 package.Version.ToString(),
                                                 apiKey
                                             });
            cmd.Execute();
        }