コード例 #1
0
        protected virtual IPackage OpenPackage(string path)
        {
            if (!FileSystem.FileExists(path))
            {
                return(null);
            }

            if (Path.GetExtension(path) == Constants.PackageExtension)
            {
                OptimizedZipPackage package;
                try
                {
                    package = new OptimizedZipPackage(FileSystem, path);
                }
                catch (InvalidDataException ex)
                {
                    throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
                }
                // Set the last modified date on the package
                package.Published = FileSystem.GetLastModified(path);

                return(package);
            }
            else if (Path.GetExtension(path) == Constants.ManifestExtension)
            {
                if (FileSystem.FileExists(path))
                {
                    return(new UnzippedPackage(FileSystem, Path.GetFileNameWithoutExtension(path)));
                }
            }

            return(null);
        }
コード例 #2
0
        protected virtual IPackage OpenPackage(string path)
        {
            if (FileSystem.FileExists(path))
            {
                OptimizedZipPackage package;
                try
                {
                    package = new OptimizedZipPackage(FileSystem, path);
                }
                catch (FileFormatException ex)
                {
                    throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
                }
                // Set the last modified date on the package
                package.Published = FileSystem.GetLastModified(path);

                return(package);
            }
            else
            {
                // if the .nupkg file doesn't exist, fall back to searching for the .nuspec file
                var nuspecPath = Path.ChangeExtension(path, Constants.ManifestExtension);
                if (FileSystem.FileExists(nuspecPath))
                {
                    return(new UnzippedPackage(FileSystem, Path.GetFileNameWithoutExtension(nuspecPath)));
                }
            }

            return(null);
        }
コード例 #3
0
        protected override IPackage OpenPackage(string path)
        {
            OptimizedZipPackage package;

            try
            {
                package = new OptimizedZipPackage(FileSystem, path);
            }
            catch (FileFormatException ex)
            {
                throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
            }

            return(package);
        }
コード例 #4
0
ファイル: NugetPush.cs プロジェクト: secretGeek/choco
        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));
        }
コード例 #5
0
ファイル: NugetService.cs プロジェクト: henkhouwaard/choco
        public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfiguration config, Action<PackageResult> continueAction)
        {
            _fileSystem.create_directory_if_not_exists(ApplicationParameters.PackagesLocation);
            var packageInstalls = new ConcurrentDictionary<string, PackageResult>(StringComparer.InvariantCultureIgnoreCase);

            //todo: handle all

            SemanticVersion version = config.Version != null ? new SemanticVersion(config.Version) : null;

            IList<string> packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList();
            if (packageNames.Count == 1)
            {
                var packageName = packageNames.DefaultIfEmpty(string.Empty).FirstOrDefault();
                if (packageName.EndsWith(Constants.PackageExtension) || packageName.EndsWith(Constants.ManifestExtension))
                {
                    this.Log().Debug("Updating source and package name to handle *.nupkg or *.nuspec file.");
                    packageNames.Clear();

                    config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(packageName));

                    if (packageName.EndsWith(Constants.ManifestExtension))
                    {
                        packageNames.Add(_fileSystem.get_file_name_without_extension(packageName));

                        this.Log().Debug("Building nuspec file prior to install.");
                        config.Input = packageName;
                        // build package
                        pack_run(config);
                    }
                    else
                    {
                        var packageFile = new OptimizedZipPackage(_fileSystem.get_full_path(packageName));
                        packageNames.Add(packageFile.Id);
                    }
                }
            }

            // this is when someone points the source directly at a nupkg
            // e.g. -source c:\somelocation\somewhere\packagename.nupkg
            if (config.Sources.to_string().EndsWith(Constants.PackageExtension))
            {
                config.Sources = _fileSystem.get_directory_name(_fileSystem.get_full_path(config.Sources));
            }

            var packageManager = NugetCommon.GetPackageManager(
                config, _nugetLogger,
                installSuccessAction: (e) =>
                    {
                        var pkg = e.Package;
                        var packageResult = packageInstalls.GetOrAdd(pkg.Id.to_lower(), new PackageResult(pkg, e.InstallPath));
                        packageResult.InstallLocation = e.InstallPath;
                        packageResult.Messages.Add(new ResultMessage(ResultType.Debug, ApplicationParameters.Messages.ContinueChocolateyAction));

                        if (continueAction != null) continueAction.Invoke(packageResult);
                    },
                uninstallSuccessAction: null,
                addUninstallHandler: true);

            foreach (string packageName in packageNames.or_empty_list_if_null())
            {
                //todo: get smarter about realizing multiple versions have been installed before and allowing that

                remove_rollback_directory_if_exists(packageName);

                IPackage installedPackage = packageManager.LocalRepository.FindPackage(packageName);

                if (installedPackage != null && (version == null || version == installedPackage.Version) && !config.Force)
                {
                    string logMessage = "{0} v{1} already installed.{2} Use --force to reinstall, specify a version to install, or try upgrade.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine);
                    var nullResult = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id)));
                    nullResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage));
                    nullResult.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));
                    this.Log().Warn(ChocolateyLoggers.Important, logMessage);
                    continue;
                }

                if (installedPackage != null && (version == null || version == installedPackage.Version) && config.Force)
                {
                    this.Log().Debug(() => "{0} v{1} already installed. Forcing reinstall.".format_with(installedPackage.Id, installedPackage.Version));
                    version = installedPackage.Version;
                }

                if (installedPackage != null && version != null && version < installedPackage.Version && !config.AllowMultipleVersions && !config.AllowDowngrade)
                {
                    string logMessage = "A newer version of {0} (v{1}) is already installed.{2} Use --allow-downgrade to attempt to install older versions, or use side by side to allow multiple versions.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine);
                    var nullResult = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id)));
                    nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
                    this.Log().Error(ChocolateyLoggers.Important, logMessage);
                    continue;
                }

                IPackage availablePackage = packageManager.SourceRepository.FindPackage(packageName, version, config.Prerelease, allowUnlisted: false);
                if (availablePackage == null)
                {
                    var logMessage = "{0} not installed. The package was not found with the source(s) listed.{1} If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.{1} Version: \"{2}\"{1} Source(s): \"{3}\"".format_with(packageName, Environment.NewLine, config.Version, config.Sources);
                    this.Log().Error(ChocolateyLoggers.Important, logMessage);
                    var noPkgResult = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, version.to_string(), null));
                    noPkgResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
                    continue;
                }

                if (installedPackage != null && (installedPackage.Version == availablePackage.Version) && config.Force)
                {
                    var forcedResult = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, installedPackage.Id)));
                    forcedResult.Messages.Add(new ResultMessage(ResultType.Note, "Backing up and removing old version"));

                    backup_existing_version(config, installedPackage, _packageInfoService.get_package_information(installedPackage));

                    try
                    {
                        packageManager.UninstallPackage(installedPackage, forceRemove: config.Force, removeDependencies: config.ForceDependencies);
                        if (!forcedResult.InstallLocation.is_equal_to(ApplicationParameters.PackagesLocation))
                        {
                            _fileSystem.delete_directory_if_exists(forcedResult.InstallLocation, recursive: true);
                        }
                    }
                    catch (Exception ex)
                    {
                        string logMessage = "{0}:{1} {2}".format_with("Unable to remove existing package prior to forced reinstall", Environment.NewLine, ex.Message);
                        this.Log().Warn(logMessage);
                        forcedResult.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));
                    }
                }

                try
                {
                    using (packageManager.SourceRepository.StartOperation(
                        RepositoryOperationNames.Install,
                        packageName,
                        version == null ? null : version.ToString()))
                    {
                        packageManager.InstallPackage(availablePackage, ignoreDependencies: config.IgnoreDependencies, allowPrereleaseVersions: config.Prerelease);
                        //packageManager.InstallPackage(packageName, version, configuration.IgnoreDependencies, configuration.Prerelease);
                    }
                }
                catch (Exception ex)
                {
                    var logMessage = "{0} not installed. An error occurred during installation:{1} {2}".format_with(packageName, Environment.NewLine, ex.Message);
                    this.Log().Error(ChocolateyLoggers.Important, logMessage);
                    var errorResult = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, version.to_string(), null));
                    errorResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
                    if (continueAction != null) continueAction.Invoke(errorResult);
                }
            }

            return packageInstalls;
        }
コード例 #6
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());
                }

            }
        }
コード例 #7
0
        protected virtual IPackage OpenPackage(string path)
        {
            if (!FileSystem.FileExists(path))
            {
                return null;
            }

            if (Path.GetExtension(path) == Constants.PackageExtension)
            {
                OptimizedZipPackage package;
                try
                {
                    package = new OptimizedZipPackage(FileSystem, path);
                }
                catch (FileFormatException ex)
                {
                    throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
                }
                // Set the last modified date on the package
                package.Published = FileSystem.GetLastModified(path);

                return package;
            }
            else if (Path.GetExtension(path) == Constants.ManifestExtension)
            {
                if (FileSystem.FileExists(path))
                {
                    return new UnzippedPackage(FileSystem, Path.GetFileNameWithoutExtension(path));
                }
            }

            return null;
        }
コード例 #8
0
        public static int Main(string[] args)
        {
            DebugHelper.WaitForAttach(ref args);

            // This is to avoid applying weak event pattern usage, which breaks under Mono or restricted environments, e.g. Windows Azure Web Sites.
            EnvironmentUtility.SetRunningFromCommandLine();

            // set output encoding to UTF8 if -utf8 is specified
            var oldOutputEncoding = System.Console.OutputEncoding;

            if (args.Any(arg => String.Equals(arg, "-utf8", StringComparison.OrdinalIgnoreCase)))
            {
                args = args.Where(arg => !String.Equals(arg, "-utf8", StringComparison.OrdinalIgnoreCase)).ToArray();
                SetConsoleOutputEncoding(System.Text.Encoding.UTF8);
            }

            var console    = new Common.Console();
            var fileSystem = new PhysicalFileSystem(Directory.GetCurrentDirectory());

            Func <Exception, string> getErrorMessage = e => e.Message;

            try
            {
                // Remove NuGet.exe.old
                RemoveOldFile(fileSystem);

                // Import Dependencies
                var p = new Program();
                p.Initialize(fileSystem, console);

                // Add commands to the manager
                foreach (ICommand cmd in p.Commands)
                {
                    p.Manager.RegisterCommand(cmd);
                }

                CommandLineParser parser = new CommandLineParser(p.Manager);

                // Parse the command
                ICommand command = parser.ParseCommandLine(args) ?? p.HelpCommand;

                // Fallback on the help command if we failed to parse a valid command
                if (!ArgumentCountValid(command))
                {
                    // Get the command name and add it to the argument list of the help command
                    string commandName = command.CommandAttribute.CommandName;

                    // Print invalid command then show help
                    console.WriteLine(LocalizedResourceManager.GetString("InvalidArguments"), commandName);

                    p.HelpCommand.ViewHelpForCommand(commandName);
                }
                else
                {
                    SetConsoleInteractivity(console, command as Command);

                    // When we're detailed, get the whole exception including the stack
                    // This is useful for debugging errors.
                    if (console.Verbosity == Verbosity.Detailed)
                    {
                        getErrorMessage = e => e.ToString();
                    }

                    command.Execute();
                }
            }
            catch (AggregateException exception)
            {
                string    message;
                Exception unwrappedEx = ExceptionUtility.Unwrap(exception);
                if (unwrappedEx == exception)
                {
                    // If the AggregateException contains more than one InnerException, it cannot be unwrapped. In which case, simply print out individual error messages
                    message = String.Join(Environment.NewLine, exception.InnerExceptions.Select(getErrorMessage).Distinct(StringComparer.CurrentCulture));
                }
                else
                {
                    message = getErrorMessage(ExceptionUtility.Unwrap(exception));
                }
                console.WriteError(message);
                return(1);
            }
            catch (Exception e)
            {
                console.WriteError(getErrorMessage(ExceptionUtility.Unwrap(e)));
                return(1);
            }
            finally
            {
                OptimizedZipPackage.PurgeCache();
                SetConsoleOutputEncoding(oldOutputEncoding);
            }

            return(0);
        }
コード例 #9
0
ファイル: InstallScenarios.cs プロジェクト: jberezanski/choco
 public void should_still_have_the_package_installed_with_the_expected_version_of_the_package()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.0.0");
 }
コード例 #10
0
ファイル: InstallScenarios.cs プロジェクト: jberezanski/choco
 public void should_not_touch_the_floating_dependency()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.0.0");
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: wayneYaw/sonarlint-vs
        public static int Main(string[] args)
        {
            DebugHelper.WaitForAttach(ref args);

            var console    = new Common.Console();
            var fileSystem = new PhysicalFileSystem(Directory.GetCurrentDirectory());

            Func <Exception, string> getErrorMessage = e => e.Message;

            try
            {
                // Remove NuGet.exe.old
                RemoveOldFile(fileSystem);

                // Import Dependencies
                var p = new Program();
                p.Initialize(fileSystem, console);

                // Add commands to the manager
                foreach (ICommand cmd in p.Commands)
                {
                    p.Manager.RegisterCommand(cmd);
                }

                CommandLineParser parser = new CommandLineParser(p.Manager);

                // Parse the command
                ICommand command = parser.ParseCommandLine(args) ?? p.HelpCommand;

                // Fallback on the help command if we failed to parse a valid command
                if (!ArgumentCountValid(command))
                {
                    // Get the command name and add it to the argument list of the help command
                    string commandName = command.CommandAttribute.CommandName;

                    // Print invalid command then show help
                    console.WriteLine(NuGetResources.InvalidArguments, commandName);

                    p.HelpCommand.ViewHelpForCommand(commandName);
                }
                else
                {
                    SetConsoleInteractivity(console, command as Command);

                    // When we're detailed, get the whole exception including the stack
                    // This is useful for debugging errors.
                    if (console.Verbosity == Verbosity.Detailed)
                    {
                        getErrorMessage = e => e.ToString();
                    }

                    command.Execute();
                }
            }
            catch (AggregateException exception)
            {
                string    message;
                Exception unwrappedEx = ExceptionUtility.Unwrap(exception);
                if (unwrappedEx == exception)
                {
                    // If the AggregateException contains more than one InnerException, it cannot be unwrapped. In which case, simply print out individual error messages
                    message = String.Join(Environment.NewLine, exception.InnerExceptions.Select(getErrorMessage).Distinct(StringComparer.CurrentCulture));
                }
                else
                {
                    message = getErrorMessage(ExceptionUtility.Unwrap(exception));
                }
                console.WriteError(message);
                return(1);
            }
            catch (Exception e)
            {
                console.WriteError(getErrorMessage(ExceptionUtility.Unwrap(e)));
                return(1);
            }
            finally
            {
                OptimizedZipPackage.PurgeCache();
            }

            return(0);
        }
コード例 #12
0
ファイル: UpgradeScenarios.cs プロジェクト: gregsdennis/choco
 public void should_upgrade_the_exact_version_dependency()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.1.0");
 }
コード例 #13
0
ファイル: UpgradeScenarios.cs プロジェクト: gregsdennis/choco
 public void should_have_the_erroring_upgraded_package_in_the_lib_bad_directory()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib-bad", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("2.0.0.0");
 }
コード例 #14
0
            async Task<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
            {
                string tmpDir = default(string);
                bool shouldDeleteTmpDir = findShortTemporaryDir(out tmpDir);

                var fs = new PhysicalFileSystem(tmpDir);
                var pkg = new OptimizedZipPackage(fs, Path.Combine(updateInfo.PackageDirectory, release.Filename));
                var target = getDirectoryForRelease(release.Version);

                // NB: This might happen if we got killed partially through applying the release
                if (target.Exists) {
                    this.Log().Warn("Found partially applied release folder, killing it: " + target.FullName);
                    await Utility.DeleteDirectory(target.FullName);
                }

                target.Create();

                // Copy all of the files out of the lib/ dirs in the NuGet package
                // into our target App directory.
                //
                // NB: We sort this list in order to guarantee that if a Net20
                // and a Net40 version of a DLL get shipped, we always end up
                // with the 4.0 version.
                this.Log().Info("Writing files to app directory: {0}", target.FullName);

                var toWrite = pkg.GetLibFiles().Where(x => pathIsInFrameworkProfile(x, appFrameworkVersion))
                    .OrderBy(x => x.Path)
                    .ToList();

                // NB: Because of the above NB, we cannot use ForEachAsync here, we 
                // have to copy these files in-order. Once we fix assembly resolution, 
                // we can kill both of these NBs.
                await Task.Run(() => toWrite.ForEach(x => copyFileToLocation(target, x)));
                await pkg.GetContentFiles().ForEachAsync(x => copyFileToLocation(target, x));

                if (shouldDeleteTmpDir) {
                    await Utility.DeleteDirectory(tmpDir);
                }

                return target.FullName;
            }
コード例 #15
0
ファイル: DeployController.cs プロジェクト: kaanjin/Monopus
        public async Task<IHttpActionResult> Upload()
        {
            if (!Request.Content.IsMimeMultipartContent())
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);

            var provider = new MultipartMemoryStreamProvider();

            await Request.Content.ReadAsMultipartAsync(provider);

            string output = null;

            foreach (var file in provider.Contents)
            {
                var filename = file.Headers.ContentDisposition.FileName.Trim('\"');

                if (!Directory.Exists(_sourcePath))
                    Directory.CreateDirectory(_sourcePath);

                var path = Path.Combine(_sourcePath, filename);

                using (var stream = File.Create(path))
                {
                    var s = await file.ReadAsByteArrayAsync();
                    await stream.WriteAsync(s, 0, s.Length);
                }

                if (!PackageHelper.IsPackageFile(path))
                {
                    var ex = new Exception("File is not a package!");
                    Log.Error(ex);
                    return InternalServerError(ex);
                }

                var pkg = new OptimizedZipPackage(path);

                try
                {
                    await pkg.Uninstall(_sourcePath, _deployOption.InstallPath);
                }
                catch (InvalidOperationException ex)
                {
                    Log.Error(ex);

                    if (!ex.Message.StartsWith("Unable to find package"))
                        throw;
                }
                catch (TimeoutException ex)
                {
                    Log.Error(ex);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    return InternalServerError(ex);
                }

                string installPath;

                try
                {
                    installPath = await pkg.Install(_sourcePath, _deployOption.InstallPath);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    return InternalServerError(ex);
                }

                string deployScript;

                if ((deployScript = await pkg.GetDeployScript()) != null)
                {
                    var args = new ListDictionary
                    {
                        {"installPath", installPath},
                        {"toolsPath", Path.Combine(installPath, "tools")},
                        {"package", pkg},
                        {"project", null}
                    };

                    if (!Script.Execute(deployScript, args, ref output))
                    {
                        var ex = new Exception(output);
                        Log.Error(ex);
                        return InternalServerError(ex);
                    }
                }
            }

            Log.InfoFormat("Deploy success: {0}", output);

            return Ok(output);
        }
コード例 #16
0
        private OptimizedZipPackage OpenPackage(string path)
        {
            OptimizedZipPackage zip = null;

            if (_fileSystem.FileExists(path))
            {
                try
                {
                    zip = new OptimizedZipPackage(_fileSystem, path);
                }
                catch (FileFormatException ex)
                {
                    throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
                }
                // Set the last modified date on the package
                zip.Published = _fileSystem.GetLastModified(path);
            }

            return zip;
        }
コード例 #17
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);

            }
        }
コード例 #18
0
ファイル: MachineCache.cs プロジェクト: rikoe/nuget
        protected override IPackage OpenPackage(string path)
        {
            OptimizedZipPackage package;
            try
            {
                package = new OptimizedZipPackage(FileSystem, path);
            }
            catch (FileFormatException ex)
            {
                throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
            }

            return package;
        }
コード例 #19
0
        protected virtual IPackage OpenPackage(string path)
        {
            if (FileSystem.FileExists(path))
            {
                OptimizedZipPackage package;
                try
                {
                    package = new OptimizedZipPackage(FileSystem, path);
                }
                catch (FileFormatException ex)
                {
                    throw new InvalidDataException(String.Format(CultureInfo.CurrentCulture, NuGetResources.ErrorReadingPackage, path), ex);
                }
                // Set the last modified date on the package
                package.Published = FileSystem.GetLastModified(path);

                return package;
            }
            else
            {
                // if the .nupkg file doesn't exist, fall back to searching for the .nuspec file
                var nuspecPath = Path.ChangeExtension(path, Constants.ManifestExtension);
                if (FileSystem.FileExists(nuspecPath))
                {
                    return new UnzippedPackage(FileSystem, Path.GetFileNameWithoutExtension(nuspecPath));
                }
            }

            return null;
        }
コード例 #20
0
ファイル: IPublishingService.cs プロジェクト: ventaur/ripple
        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);
        }
コード例 #21
0
ファイル: InstallScenarios.cs プロジェクト: jberezanski/choco
 public void should_install_the_expected_version_of_the_package()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "installpackage", "installpackage" + Constants.PackageExtension);
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.0.0");
 }
コード例 #22
0
ファイル: UpgradeScenarios.cs プロジェクト: gregsdennis/choco
 public void should_upgrade_the_parent_package_to_lowest_version_that_meets_new_dependency_version()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.1.0");
 }
コード例 #23
0
ファイル: InstallScenarios.cs プロジェクト: jberezanski/choco
 public void should_install_the_expected_version_of_the_dependency()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.0.0.0");
 }
コード例 #24
0
ファイル: UpgradeScenarios.cs プロジェクト: gregsdennis/choco
 public void should_upgrade_the_package()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.1.0.0");
 }
コード例 #25
0
ファイル: InstallScenarios.cs プロジェクト: jberezanski/choco
 public void should_reinstall_the_floating_dependency_with_the_latest_version_that_satisfies_the_dependency()
 {
     var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
     var package = new OptimizedZipPackage(packageFile);
     package.Version.Version.to_string().ShouldEqual("1.1.0.0");
 }