示例#1
0
        public void BuildExternal()
        {
            ProcessStartInfo psi = new ProcessStartInfo(MSBuild, string.Format("/nologo \"{0}\" /v:q /p:Configuration={1} \"/logger:MSBuildLogger,{2};OutputDir={3};Indent=true\"", Solution, OtherConfiguration, Logger, LoggerPath));

            psi.UseShellExecute        = false;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError  = true;
            psi.CreateNoWindow         = true;

            using (Process p = Process.Start(psi))
            {
                p.WaitForExit();
                string output = p.StandardOutput.ReadToEnd();
                string err    = p.StandardError.ReadToEnd();

                Assert.That(err, Is.EqualTo(""), "MSBuild gave no error");
                //Assert.That(output, Is.EqualTo(""), "MSBuild gave no output");
                Assert.That(p.ExitCode, Is.EqualTo(0), "MSBuild ran successfully");
            }

            Assert.That(File.Exists(QQnPath.Combine(LoggerPath, "QQn.TurtleMSBuild.tbLog")), Is.True, "Logfile created");

            XPathDocument doc = new XPathDocument(QQnPath.Combine(LoggerPath, "QQn.TurtleMSBuild.tbLog"));

            XPathNavigator      nav   = doc.CreateNavigator();
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(nav.NameTable);

            nsMgr.AddNamespace("tb", "http://schemas.qqn.nl/2007/TurtleBuild/BuildResult");
            Assert.That(nav.SelectSingleNode("/tb:TurtleBuildData/tb:Configuration", nsMgr).GetAttribute("outputPath", ""), Is.Not.EqualTo(""), "outputPath is set");
            //doc.CreateNavigator().SelectSingleNode("

            TBLogFile file = TBLogFile.Load(QQnPath.Combine(LoggerPath, "QQn.TurtleMSBuild.tbLog"));

            Assert.That(file, Is.Not.Null);
            Assert.That(file.Configurations.Count, Is.GreaterThanOrEqualTo(1), "Configurations available");

            Assert.That(file.Configurations[0].ProjectOutput.Items.Count, Is.GreaterThan(1));

            Assert.That(file.Configurations[0].ProjectOutput.Items[0].Container, Is.SameAs(file.Configurations[0].ProjectOutput), "Container is set");

            Assert.That(file.Configurations[0].Target.DebugSrc, Is.Not.Null);


            using (StringWriter sw = new StringWriter())
            {
                using (XmlWriter xw = new XmlTextWriter(sw))
                {
                    xw.WriteStartDocument();
                    xw.WriteStartElement("TurtleBuild", "q:q");
                    QQn.TurtleUtils.Tokens.Tokenizer.TryWriteXml(new XmlTextWriter(sw), file);

                    xw.WriteEndDocument();
                }

                string text = sw.ToString();
                Assert.That(text.Length, Is.GreaterThan(100));
            }
        }
示例#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);
            }
        }