private static void ParseProjectReferences(XDocument projectFileDoc, XNamespace @namespace, ProjectFile projectFile) { foreach (var referenceNode in projectFileDoc.Descendants(@namespace + "ProjectReference")) { projectFile.AddProjectReference(new ProjectReference(referenceNode.Attribute("Include").Value)); } }
public void WriteToFile(ProjectFile projectFile) { if (_writer == null) _writer = File.CreateText(_fileName); _writer.WriteLine("----------------------------------------------------"); _writer.WriteLine("Project: " + projectFile.FileName); WriteBuildOutputDirectorySection(projectFile); WriteProjectReferencesSection(projectFile); }
private ProjectFile ProcessFile(string file) { var projectFile = new ProjectFile(file); var projectFileDoc = XDocument.Load(file); XNamespace @namespace = ""; if (projectFileDoc.Root != null) @namespace = projectFileDoc.Root.Name.Namespace; ParseBuildDirectory(projectFileDoc, @namespace, projectFile); ParseProjectReferences(projectFileDoc, @namespace, projectFile); return projectFile; }
private void ParseBuildDirectory(XDocument projectFileDoc, XNamespace @namespace, ProjectFile projectFile) { var node = (from g in projectFileDoc.Descendants(@namespace + "PropertyGroup") let config = g.Attribute("Condition") where config != null && config.Value.ToLowerInvariant() == " '$(configuration)|$(platform)' == '" + _buildConfiguration + "|" + _buildPlatform + "' " select g.Element(@namespace + "OutputPath")).FirstOrDefault(); if (node != null) { projectFile.SetBuildOutputDirectory(node.Value); } }
private void WriteProjectReferencesSection(ProjectFile projectFile) { _writer.Write("\tProject References: "); if (projectFile.ProjectReferences.Any()) { _writer.WriteLine(""); foreach (var reference in projectFile.ProjectReferences) { _writer.WriteLine("\t\t" + reference.ReferencedProjectFile); } } else { _writer.WriteLine("None Found"); } }
private void WriteBuildOutputDirectorySection(ProjectFile projectFile) { _writer.WriteLine("\tBuild Output (relative): " + projectFile.BuildOutputDirectoryRelative); _writer.WriteLine("\tBuild Output (absolute): " + projectFile.BuildOutputDirectoryAbsolute); }