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; } } } } }
private void ParseProjectFile(string fullConfiguration, Project parentProject) { if (_parsed) { return; } _parsed = true; TagPropertyCollection tpc = new TagPropertyCollection(); string[] items = fullConfiguration.Split('|'); ProjectConfiguration = items[0]; ProjectPlatform = items[1]; tpc.Set("PlatformName", ProjectPlatform); tpc.Set("ConfigurationName", ProjectConfiguration); Solution solution = parentProject as Solution; if (solution != null) { tpc.Set("SolutionDir", QQnPath.NormalizePath(solution.ProjectPath, true)); tpc.Set("SolutionPath", QQnPath.NormalizePath(solution.ProjectFile)); tpc.Set("SolutionName", solution.ProjectName); tpc.Set("SolutionFileName", Path.GetFileName(ProjectFile)); } tpc.Set("ProjectDir", QQnPath.NormalizePath(ProjectPath, true)); tpc.Set("ProjectPath", QQnPath.NormalizePath(ProjectFile)); tpc.Set("ProjectName", ProjectName); tpc.Set("ProjectFileName", Path.GetFileName(ProjectFile)); tpc.Set("ProjectExt", Path.GetExtension(ProjectFile)); using (StreamReader sr = File.OpenText(ProjectFile)) { XPathDocument doc = new XPathDocument(sr); XPathNavigator dn = doc.CreateNavigator(); TargetName = dn.SelectSingleNode("/VisualStudioProject").GetAttribute("Name", ""); tpc.Set("TargetName", TargetName); tpc.Set("ProjectName", TargetName); XPathNavigator config = dn.SelectSingleNode("//Configurations/Configuration[@Name='" + FullProjectConfiguration + "']"); XPathNavigator compiler = config.SelectSingleNode("Tool[@Name='VCCLCompilerTool']"); XPathNavigator linker = config.SelectSingleNode("Tool[@Name='VCLinkerTool']"); if (string.IsNullOrEmpty(TargetName) || config == null || compiler == null) { TargetName = null; return; // No .Net assembly output } OutputPath = tpc.ExpandProperties(config.GetAttribute("OutputDirectory", "")); tpc.Set("OutDir", QQnPath.NormalizePath(GetFullPath(OutputPath), true)); string intPath = tpc.ExpandProperties(config.GetAttribute("IntermediateDirectory", "")); intPath = GetFullPath(intPath); tpc.Set("IntDir", QQnPath.NormalizePath(intPath, true)); ProjectOutput.BaseDirectory = ProjectPath; switch (int.Parse(config.GetAttribute("ConfigurationType", "").Trim(), NumberStyles.None)) { case 1: TargetExt = ".exe"; break; case 4: TargetExt = ".lib"; linker = config.SelectSingleNode("Tool[@Name='VCLibrarianTool']"); break; case 2: default: TargetExt = ".dll"; break; } tpc.Set("TargetExt", TargetExt); string tp = linker.GetAttribute("OutputFile", ""); if (!string.IsNullOrEmpty(tp)) { tp = tpc.ExpandProperties(tp); if (!string.IsNullOrEmpty(tp)) { tp = EnsureRelativePath(tp); TargetName = Path.GetFileNameWithoutExtension(tp); TargetExt = Path.GetExtension(tp); tpc.Set("TargetExt", TargetExt); if (!string.Equals(TargetPath, tp, StringComparison.OrdinalIgnoreCase)) { TargetPath = tp; // Only set the override if the construction was not ok } } } if (!File.Exists(GetFullPath(TargetPath)) || linker == null) { TargetName = null; return; // Something went wrong.. Check project format } string mc = config.GetAttribute("ManagedExtensions", ""); if (!string.IsNullOrEmpty(mc)) { switch (int.Parse(mc.Trim(), NumberStyles.None)) { case 0: break; // No clr? case 1: default: IsAssembly = QQnPath.IsAssemblyFile(TargetPath); break; } } string value = TargetPath; ProjectOutput.Add(new TargetItem(value, value, TargetType.Item)); if (string.Equals(compiler.GetAttribute("GenerateXMLDocumentationFiles", ""), "true", StringComparison.OrdinalIgnoreCase)) { string xmlFile = Path.ChangeExtension(value, ".xml"); if (File.Exists(GetFullPath(xmlFile))) { ProjectOutput.Add(new TargetItem(xmlFile, xmlFile, TargetType.Item)); } } if (string.Equals(linker.GetAttribute("GenerateDebugInformation", ""), "true", StringComparison.OrdinalIgnoreCase)) { string pdbFile = Path.ChangeExtension(value, ".pdb"); if (File.Exists(GetFullPath(pdbFile))) { ProjectOutput.Add(new TargetItem(pdbFile, pdbFile, TargetType.Item)); } } if (!string.IsNullOrEmpty(value = linker.GetAttribute("KeyFile", ""))) { KeyFile = EnsureRelativePath(tpc.ExpandProperties(value)); } if (!string.IsNullOrEmpty(value = linker.GetAttribute("KeyContainer", ""))) { KeyContainer = value; } FindContentAndScripts(doc); } }