Esempio n. 1
0
        private IPackage createPackage(PackageBuilder builder, string outputPath)
        {
            bool isExistingPackage = File.Exists(outputPath);

            try
            {
                using (Stream stream = File.Create(outputPath))
                {
                    builder.Save(stream);
                }
            }
            catch (Exception exc)
            {
                if (!isExistingPackage && File.Exists(outputPath))
                {
                    File.Delete(outputPath);
                }

                RippleAssert.Fail("Error creating package: " + exc.Message);
            }

            RippleLog.Info("Created nuget at: " + outputPath);
            return(new OptimizedZipPackage(outputPath));
        }
Esempio n. 2
0
        public override bool Execute(InitInput input)
        {
            var rippleConfigDirectory = RippleFileSystem.FindSolutionDirectory(false);

            if (rippleConfigDirectory.IsNotEmpty())
            {
                RippleAssert.Fail(ExistingSolution.ToFormat(rippleConfigDirectory));
                return(false);
            }

            SolutionFiles.AddLoader(new NuGetSolutionLoader());

            var builder  = Builder();
            var solution = builder.Build();

            solution.Save(true);

            new CleanCommand().Execute(new CleanInput());
            new RestoreCommand().Execute(new RestoreInput {
                FixReferencesFlag = true
            });

            return(true);
        }
Esempio n. 3
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null)
        {
            var plan     = new NugetPlan();
            var target   = request.Dependency;
            var solution = request.Solution;

            var dependencyKey = target.Copy();

            if (dependencyKey.IsFloat())
            {
                dependencyKey = target.AsFloat();
            }

            var key = new PlanKey(dependencyKey, request.Project);

            if (_planCache.Has(key))
            {
                return(_planCache[key]);
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                string version = null;
                var    local   = solution.LocalDependencies();

                if (request.Operation == OperationType.Install && solution.LocalDependencies().Has(target))
                {
                    var localNuget = local.Get(target);
                    version = localNuget.Version.ToString();
                }
                else
                {
                    if (!RippleEnvironment.Connected())
                    {
                        RippleAssert.Fail("Cannot update in offline mode");
                    }

                    var task = solution.FeedService.NugetFor(target);
                    task.Wait();

                    if (!task.Result.Found)
                    {
                        RippleAssert.Fail("Could not find " + request.Dependency);
                    }
                    var remote = task.Result.Nuget;
                    version = remote.Version.ToString();
                }

                target.Version = version;
            }

            if (request.UpdatesCurrentDependency())
            {
                updateDependency(plan, request);
            }
            else if (!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var location = request.Operation == OperationType.Install ? SearchLocation.Local : SearchLocation.Remote;

            var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode, location);

            nugetDependencies.Each(x =>
            {
                var transitiveDep = request.CopyFor(x);
                var childPlan     = buildPlan(transitiveDep, target);
                plan.Import(childPlan);
            });

            return(plan);
        }