private bool LoadVS2003Project(string projectDirectory, XmlDocument doc) { XmlNode settingsNode = doc.SelectSingleNode("/VisualStudioProject/*/Build/Settings"); if (settingsNode == null) { return(false); } string assemblyName = RequiredAttributeValue(settingsNode, "AssemblyName"); string outputType = RequiredAttributeValue(settingsNode, "OutputType"); if (outputType == "Exe" || outputType == "WinExe") { assemblyName = assemblyName + ".exe"; } else { assemblyName = assemblyName + ".dll"; } XmlNodeList nodes = settingsNode.SelectNodes("Config"); if (nodes != null) { foreach (XmlNode configNode in nodes) { string name = RequiredAttributeValue(configNode, "Name"); string outputPath = RequiredAttributeValue(configNode, "OutputPath"); string outputDirectory = Path.Combine(projectDirectory, outputPath); string assemblyPath = Path.Combine(outputDirectory, assemblyName); VSProjectConfig config = new VSProjectConfig(name); config.Assemblies.Add(assemblyPath); configs.Add(config); } } return(true); }
public void Load() { if (!IsProjectFile(projectPath)) { ThrowInvalidFileType(projectPath); } string projectDirectory = Path.GetFullPath(Path.GetDirectoryName(projectPath)); try { XmlDocument doc = new XmlDocument(); doc.Load(projectPath); string extension = Path.GetExtension(projectPath); string assemblyName; switch (extension) { case ".vcproj": foreach (XmlNode configNode in doc.SelectNodes("/VisualStudioProject/Configurations/Configuration")) { string name = configNode.Attributes["Name"].Value; string outputPath = configNode.Attributes["OutputDirectory"].Value; string outputDirectory = Path.Combine(projectDirectory, outputPath); XmlNode toolNode = configNode.SelectSingleNode("Tool[@Name='VCLinkerTool']"); assemblyName = Path.GetFileName(toolNode.Attributes["OutputFile"].Value); string assemblyPath = Path.Combine(outputDirectory, assemblyName); VSProjectConfig config = new VSProjectConfig(name); config.Assemblies.Add(assemblyPath); this.configs.Add(config); } break; case ".csproj": case ".vbproj": case ".vjsproj": XmlNode settingsNode = doc.SelectSingleNode("/VisualStudioProject/*/Build/Settings"); assemblyName = settingsNode.Attributes["AssemblyName"].Value; string outputType = settingsNode.Attributes["OutputType"].Value; if (outputType == "Exe" || outputType == "WinExe") { assemblyName = assemblyName + ".exe"; } else { assemblyName = assemblyName + ".dll"; } XmlNodeList nodes = settingsNode.SelectNodes("Config"); if (nodes != null) { foreach (XmlNode configNode in nodes) { string name = configNode.Attributes["Name"].Value; string outputPath = configNode.Attributes["OutputPath"].Value; string outputDirectory = Path.Combine(projectDirectory, outputPath); string assemblyPath = Path.Combine(outputDirectory, assemblyName); VSProjectConfig config = new VSProjectConfig(name); config.Assemblies.Add(assemblyPath); configs.Add(config); } } break; default: break; } } catch (FileNotFoundException) { throw; } catch (Exception e) { ThrowInvalidFormat(projectPath, e); } }