Ejemplo n.º 1
0
        /// <summary>
        /// Tries to create packages from the specified logfiles; walking dependencies if needed.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <param name="newPackages">The new packages.</param>
        /// <returns></returns>
        public static bool TryCreatePackages(PackageArgs args, out PackageList newPackages)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            PackageState state = new PackageState(args);

            state.LoadExternalOrigins();
            state.CreateBuildOrigins();
            state.AddRequirements();

            state.CalculateDependencies();

            newPackages = new PackageList();

            List <TBLogFile> filesToRun = new List <TBLogFile>(state.Logs);

            while (filesToRun.Count > 0)
            {
                int n = 0;
                for (int i = 0; i < filesToRun.Count; i++)
                {
                    TBLogFile file = filesToRun[i];
                    if (state.CanPackage(file))
                    {
                        filesToRun.RemoveAt(i--);

                        string   target     = QQnPath.Combine(args.OutputDir, file.Project.Name + ".tpZip");
                        FileInfo targetInfo = new FileInfo(target);

                        TPack pack;
                        if (targetInfo.Exists && targetInfo.LastWriteTime > file.GetLastWriteTime())
                        {
                            pack = TPack.OpenFrom(target, VerificationMode.None);
                            state.SetOriginPack(file, pack.Pack);
                        }
                        else
                        {
                            pack = TPack.Create(target, state.CreateDefinition(file));
                        }
                        newPackages.Add(target, pack);
                        n++;
                    }
                }

                if (n == 0)
                {
                    break; // Can't package anything
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public PackageState(PackageArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            _logCache = args.LogCache;

            foreach (string file in args.ProjectsToPackage.KeysAsFullPaths)
            {
                Logs.Add(LogCache.Get(file));
            }

            _buildRoot = args.BuildRoot;
            _dontUseProjectDependencies = !args.UseProjectDependencies;

            if (!string.IsNullOrEmpty(BuildRoot))
            {
                Files.BaseDirectory = args.BuildRoot;
            }
        }