コード例 #1
0
        public virtual void PostParseBuildResult()
        {
            if (string.IsNullOrEmpty(TargetPath) || string.IsNullOrEmpty(ProjectPath))
            {
                return;
            }

            if ((DebugSrc == null) || (DebugId == null))
            {
                string targetFile = GetFullPath(TargetPath);

                if (QQnPath.IsAssemblyFile(targetFile) && File.Exists(targetFile))
                {
                    DebugReference reference = AssemblyUtils.GetDebugReference(targetFile);

                    if (reference != null)
                    {
                        string   pdbSrc    = EnsureRelativePath(QQnPath.Combine(ProjectPath, Path.GetDirectoryName(TargetPath), reference.PdbFile));
                        FileInfo pdbTarget = new FileInfo(Path.GetFullPath(QQnPath.Combine(ProjectPath, Path.GetDirectoryName(TargetPath), Path.GetFileName(pdbSrc))));

                        if (pdbTarget.Exists)
                        {
                            FileInfo pdbFrom = new FileInfo(GetFullPath(pdbSrc));

                            if (!pdbFrom.Exists || ((pdbFrom.Length == pdbTarget.Length) && (pdbFrom.LastWriteTime == pdbTarget.LastWriteTime)))
                            {
                                pdbSrc = EnsureRelativePath(pdbTarget.FullName);
                            }
                        }

                        DebugSrc = pdbSrc;
                        DebugId  = reference.DebugId;
                    }
                    else
                    {
                        string pdbFile = Path.ChangeExtension(targetFile, ".pdb");

                        if (ProjectOutput.ContainsKey(pdbFile) && File.Exists(pdbFile))
                        {
                            pdbFile = EnsureRelativePath(pdbFile);

                            DebugSrc = pdbFile;
                        }
                    }
                }
            }
        }
コード例 #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);
            }
        }