PushPackage() public method

Pushes a package to the server that is represented by the stream.
public PushPackage ( string apiKey, Stream packageStream, int timeout ) : void
apiKey string API key to be used to push the package.
packageStream Stream Stream representing the package.
timeout int Time in milliseconds to timeout the server request.
return void
        public void Push(string url, string key, Stream stream)
        {
            var package = new ZipPackage(stream);
            stream = package.GetStream();

            var server = new PackageServer(url, "SymbolSource");
            server.PushPackage(key, package, stream.Length, 5000, false);
        }
Beispiel #2
0
        public void PublishPackage(string file, string apiKey)
        {
            var packageServer = new PackageServer(Feed.NuGetV2.Url, "ripple");
            var package = new ZipPackage(file);

            RippleLog.Info("Publishing " + file);
            packageServer.PushPackage(apiKey, package.GetStream, (int)60.Minutes().TotalMilliseconds);
        }
 /// <summary>Publishes to the NuGet main repository.</summary>
 public static void PublishToNuget(string packagePath, string nugetApiKey)
 {
     TraceSource.TraceEvent(TraceEventType.Verbose, "Pushing \"{0}\" to NuGet repository", packagePath);
     PackageServer packageServer = new PackageServer("https://nuget.org/", "Google.Apis");
     try
     {
         packageServer.PushPackage(nugetApiKey, new ZipPackage(packagePath), NuGetPushTimeoutMills);
         TraceSource.TraceEvent(TraceEventType.Information, "\"{0}\" was pushed successfully", packagePath);
     }
     catch (Exception ex)
     {
         TraceSource.TraceEvent(TraceEventType.Error, "Can't publish \"{0}\" to NuGet repository. " +
             "Exception is: {1}", packagePath, ex.Message);
     }
 }
        // POST /api/sign
        public async Task<HttpResponseMessage> Post([FromBody]WebHookEvent payload)
        {
            if (payload.Payload.PackageIdentifier.EndsWith(ConfigurationManager.AppSettings["Signature:PackageIdSuffix"]))
            {
                return new HttpResponseMessage(HttpStatusCode.OK) {ReasonPhrase = "Package is already signed. "};
            }

            string tempPath = Path.GetTempFileName();
            try
            {
                // Download the package
                var httpClient = new HttpClient();
                var packageStream = await httpClient.GetStreamAsync(payload.Payload.PackageDownloadUrl);

                using (var stream = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    packageStream.CopyTo(stream);
                }

                // Sign the package
                PackageSigner signer = new PackageSigner();
                if (signer.SignPackage(tempPath, tempPath,
                    ConfigurationManager.AppSettings["Signature:KeyFile"],
                    ConfigurationManager.AppSettings["Signature:KeyFilePassword"],
                    payload.Payload.PackageIdentifier + ConfigurationManager.AppSettings["Signature:PackageIdSuffix"]))
                {
                    var server = new PackageServer(ConfigurationManager.AppSettings["Signature:NuGetFeedUrl"], "Signature/1.0");
                    server.PushPackage(ConfigurationManager.AppSettings["Signature:NuGetFeedApiKey"], new OptimizedZipPackage(tempPath), new FileInfo(tempPath).Length, 60 * 1000, true);
                    OptimizedZipPackage.PurgeCache();

                    return new HttpResponseMessage(HttpStatusCode.Created) { ReasonPhrase = "Package has been signed." };
                }
            }
            finally
            {
                File.Delete(tempPath);
            }

            return new HttpResponseMessage(HttpStatusCode.OK) { ReasonPhrase = "Package is already signed." };
        }
Beispiel #5
0
        public static void push_package(ChocolateyConfiguration config, string nupkgFilePath)
        {
            var timeout = TimeSpan.FromSeconds(Math.Abs(config.PushCommand.TimeoutInSeconds));
            if (timeout.Seconds <= 0)
            {
                timeout = TimeSpan.FromMinutes(5); // Default to 5 minutes
            }
            const bool disableBuffering = false;

            var packageServer = new PackageServer(config.Sources, ApplicationParameters.UserAgent);
            packageServer.SendingRequest += (sender, e) => { if (config.Verbose) "chocolatey".Log().Info(ChocolateyLoggers.Verbose, "{0} {1}".format_with(e.Request.Method, e.Request.RequestUri)); };

            var package = new OptimizedZipPackage(nupkgFilePath);

            try
            {
                packageServer.PushPackage(
                    config.PushCommand.Key,
                    package,
                    new FileInfo(nupkgFilePath).Length,
                    Convert.ToInt32(timeout.TotalMilliseconds),
                    disableBuffering);
            }
            catch (InvalidOperationException ex)
            {
                var message = ex.Message;
                if (!string.IsNullOrWhiteSpace(message) && message.Contains("(500) Internal Server Error"))
                {
                    throw new ApplicationException("There was an internal server error, which might mean the package already exists on a Simple OData Server.", ex);
                }

                throw;
            }


            "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0} was pushed successfully to {1}".format_with(package.GetFullName(), config.Sources));
        }
Beispiel #6
0
        public void PublishPackage(string file, string apiKey)
        {
            var packageServer = new PackageServer("https://nuget.org/", "ripple");
            var package = new OptimizedZipPackage(file);

            RippleLog.Info("Publishing " + file + " with " + apiKey);

            packageServer.PushPackage(apiKey, package, (int)60.Minutes().TotalMilliseconds);
        }
Beispiel #7
0
        public void PublishPackage(string serverUrl, string file, string apiKey)
        {
            var packageServer = new PackageServer(serverUrl, "ripple");
            var package = new OptimizedZipPackage(file);

            RippleLog.Info("Publishing " + file + " with " + apiKey);

            try
            {
                packageServer.PushPackage(apiKey, package, (int) 60.Minutes().TotalMilliseconds);
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message.Contains("already exists"))
                {
                    ConsoleWriter.Write(ConsoleColor.Yellow, "File {0} already exists on the server".ToFormat(file));
                }
                else
                {
                    ConsoleWriter.Write(ConsoleColor.Red, "File {0} failed!");
                    ConsoleWriter.Write(ConsoleColor.Red, ex.ToString());
                }

            }
        }
        void WritePackage(PackageBuilder builder, ManifestMetadata metadata)
        {
            //Create the Nuget package
            if (!Directory.Exists(NugetRepository)) Directory.CreateDirectory(NugetRepository);

            var package = NugetRepository + metadata.Id + NugetSeparator + metadata.Version + ".nupkg";
            using (FileStream stream = File.Open(package, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
                {
                    builder.Populate(metadata);
                    builder.Save(stream);
                }
                Trace.TraceInformation("Package {0} created locally", package);
                
                var localRepo = PackageRepositoryFactory.Default.CreateRepository(new DirectoryInfo("./nuget-repository").FullName);
                var nuGetPackage = PackageHelper.ResolvePackage(localRepo, metadata.Id, new SemanticVersion(metadata.Version));
                var packageFile = new FileInfo(package);
                var size = packageFile.Length;
                var ps = new PackageServer(_repository, "None");
                ps.PushPackage(_credential, nuGetPackage, size, 50000, false);
               
                Trace.TraceInformation("Package {0} uploaded to {1}", package, _repository);
        }
Beispiel #9
0
 void INuGetServer.PushPackage(IPackage package)
 {
     var server = new PackageServer(_settings.Url, "NuGet Command Line");
     server.PushPackage(_settings.Key, package, 10000);
 }
Beispiel #10
0
        public IPublishReportItem PublishPackage(string serverUrl, string file, string apiKey)
        {
            var packageServer = new PackageServer(serverUrl, "ripple");
            var package = new OptimizedZipPackage(file);

            RippleLog.Info("Publishing " + file + " with " + apiKey);

            try
            {
                var info = new FileInfo(file);
                packageServer.PushPackage(apiKey, package, info.Length, (int)60.Minutes().TotalMilliseconds);
                return new PublishSuccessful(package);
            }
            catch (Exception ex)
            {
                // TODO -- Hate this
                if (ex.Message.Contains("exists"))
                {
                    return new VersionAlreadyExists(package);
                }

                return new PublishFailure(package, ex);

            }
        }
 public void Push(string url, string key, Stream stream)
 {
     var server = new PackageServer(url, "SymbolSource");
     server.PushPackage(key, stream, 5000);
 }