Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        private IPackage FindPackage(bool createLogger, out string path)
        {
            path = null;
            var dir = CommonHelper.MapPath(UpdatePackagePath, false);

            if (!Directory.Exists(dir))
            {
                return(null);
            }

            var files = Directory.GetFiles(dir, "SmartStore.*.nupkg", SearchOption.TopDirectoryOnly);

            // TODO: allow more than one package in folder and return newest
            if (files.Length == 0 || files.Length > 1)
            {
                return(null);
            }

            try
            {
                path = files[0];
                IPackage package = new ZipPackage(files[0]);
                if (createLogger)
                {
                    _logger = CreateLogger(package);
                    _logger.Information("Found update package '{0}'".FormatInvariant(package.GetFullName()));
                }
                return(package);
            }
            catch { }

            return(null);
        }
Esempio n. 3
0
        private string DoConfigure(string packagePath, Environment env, string outputPath)
        {
            _logger.InfoFormat("Configuring package {0} for {1}", new FileInfo(packagePath).Name, env.Name.ToUpper());
            var workingDir = _fileSystem.CreateTempWorkingDir();

            _logger.DebugFormat("Create temp work dir {0}", workingDir);

            // read nupkg metadata
            var nupkg = new ZipPackage(packagePath);

            _logger.DebugFormat("Unzipping {0} to {1}", nupkg.GetFullName(), workingDir);

            using (var zip = new ZipFile(packagePath))
            {
                zip.ExtractAll(workingDir);
            }

            _templateEngine.TransformDirectory(workingDir, env);
            var packageName       = nupkg.Id + "_v" + nupkg.Version + "_" + env.Name.ToUpper(CultureInfo.InvariantCulture) + ".nupkg";
            var packageOutputPath = Path.Combine(outputPath, packageName);

            _fileSystem.DeleteFile(packageOutputPath);

            using (var zip = new ZipFile(packageOutputPath))
            {
                zip.AddDirectory(workingDir);
                zip.Save();
            }

            _fileSystem.DeleteDirectory(workingDir);

            return(packageOutputPath);
        }
Esempio n. 4
0
        private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout)
        {
            // Push the package to the server
            var package = new ZipPackage(packageToPush);

            string sourceName = CommandLineUtility.GetSourceDisplayName(source);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), sourceName);

            packageServer.PushPackage(apiKey, package.GetStream, Convert.ToInt32(timeout.TotalMilliseconds));
            Console.WriteLine(NuGetResources.PushCommandPackagePushed);
        }
Esempio n. 5
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();
        }
Esempio n. 6
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);

            //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 (package.GetStream())
                {
                    var fileSize = new FileInfo(packagePath).Length;
                    packageServer.PushPackage(apiKey, package, fileSize, 60000, false);
                }
            }
            catch
            {
                Console.WriteLine();
                throw;
            }
        }
Esempio n. 7
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();
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
0
        private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout)
        {
            // Push the package to the server
            var package = new ZipPackage(packageToPush);

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

            using (Stream stream = package.GetStream())
            {
                packageServer.PushPackage(apiKey, stream, Convert.ToInt32(timeout.TotalMilliseconds));
            }

            if (CreateOnly)
            {
                Console.WriteWarning(NuGetResources.Warning_PublishPackageDeprecated);
            }
            Console.WriteLine(NuGetResources.PushCommandPackagePushed);
        }
Esempio n. 10
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();
        }
Esempio n. 11
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);

            //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 (package.GetStream())
                {
                    packageServer.PushPackage(apiKey, package, 60000);
                }
            }
            catch 
            {
                Console.WriteLine();
                throw;
            }
        }
Esempio n. 12
0
        private void PushPackage(string packagePath, string source, string apiKey)
        {
            var packageServer = new PackageServer(source, CommandLineConstants.UserAgent);

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

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

            using (Stream stream = package.GetStream())
            {
                packageServer.PushPackage(apiKey, stream);
            }

            if (CreateOnly)
            {
                Console.WriteWarning(NuGetResources.Warning_PublishPackageDeprecated);
            }
            Console.WriteLine(NuGetResources.PushCommandPackagePushed);
        }
Esempio n. 13
0
        private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout)
        {
            // Push the package to the server
            var package = new ZipPackage(packageToPush);

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

            packageServer.PushPackage(apiKey, package, Convert.ToInt32(timeout.TotalMilliseconds));
            Console.WriteLine(NuGetResources.PushCommandPackagePushed);
        }