public override void ParseBuildResult(Project parentProject) { base.ParseBuildResult(parentProject); ParseProjectFile(FullProjectConfiguration, parentProject); if (string.IsNullOrEmpty(TargetPath)) { return; } if (IsAssembly) { Assembly asm = AssemblyUtils.GetCachedReflectionAssembly(GetFullPath(TargetPath)); TargetAssembly = new AssemblyReference(asm.FullName, ProjectOutput[TargetPath]); foreach (Module m in asm.GetModules(true)) { string file = EnsureRelativePath(m.FullyQualifiedName); if (!ProjectOutput.Contains(file)) { ProjectOutput.Add(new TargetItem(file, file, TargetType.Item)); } } ResolveAdditionalOutput(asm); } }
private void AddItem(bool local, TargetType type, ITaskItem item) { string path = item.ItemSpec; string src = EnsureRelativePath(path); string target = (item != null) ? EnsureRelativePath(CalculateTarget(item)) : src; if (!ProjectOutput.ContainsKey(target)) { ProjectOutput.Add(new TargetItem(target, src, local ? type : (TargetType)((int)type | 0x10))); } }
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); } }