Esempio 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);
        }
Esempio n. 2
0
        public void MakePackage()
        {
            string logFile = QQnPath.Combine(LoggerPath, "QQn.TurtleMSBuild.tbLog");

            if (!File.Exists(logFile))
            {
                BuildInternal();
            }

            TBLogFile log = TBLogFile.Load(logFile);

            Assert.That(!string.IsNullOrEmpty(log.Project.Name));

            DebugReference reference = null;

            foreach (TBLogItem item in log.Configurations[0].ProjectOutput.Items)
            {
                if (!item.IsShared && !item.IsCopy)
                {
                    switch (Path.GetExtension(item.Src).ToUpperInvariant())
                    {
                    case ".PDB":
                    case ".DLL":
                        if (reference == null)
                        {
                            reference = AssemblyUtils.GetDebugReference(item.FullSrc);

                            Assert.That(reference, Is.Not.Null);
                            Assert.That(reference.PdbFile, Is.Not.Null);
                        }
                        else
                        {
                            DebugReference dr = AssemblyUtils.GetDebugReference(item.FullSrc);

                            Assert.That(dr, Is.Not.Null);
                            // Path does not have to equal; the pdb information contains the sourcepath (obj directory for c# code)
                            Assert.That(Path.GetFileName(dr.PdbFile), Is.EqualTo(Path.GetFileName(reference.PdbFile)));
                            Assert.That(dr.DebugId, Is.EqualTo(reference.DebugId));
                        }
                        break;
                    }
                }
            }

            Pack pack = null;

            Assert.That(PackUtils.TryCreatePack(log, out pack));

            string path = QQnPath.Combine(PackagePath, "QQn.TurtleMSBuild.tpZip");
            TPack  tp   = TPack.Create(path, pack);

            using (TPack pkg = TPack.OpenFrom(path, VerificationMode.Full))
                using (DirectoryMap dm = DirectoryMap.Get(ExtractPath))
                {
                    Assert.That(pkg, Is.Not.Null);

                    pkg.ExtractTo(dm);
                }

            using (TPack pkg = TPack.OpenFrom(path, VerificationMode.Full))
            {
                Assert.That(pkg, Is.Not.Null);

                pkg.ExtractTo(ExtractPath);
            }
        }