LINQ / Xml バージョンを次の場所に投稿しました。
http://granadacoder.wordpress.com/2012/10/11/how-to-find-references-in-ac-project-file-csproj-using-linq-xml/
しかし、ここにその要点があります。100% 完璧ではないかもしれませんが、アイデアは示されています。
答えを探しているときにこれ(元の投稿)を見つけたので、ここにコードを投稿します。それから私は検索に飽きて、自分で書きました。
using System;
using System.Linq;
using System.Xml.Linq;
string fileName = @"C:\MyFolder\MyProjectFile.csproj";
XDocument xDoc = XDocument.Load(fileName);
XNamespace ns = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
//References "By DLL (file)"
var list1 = from list in xDoc.Descendants(ns + "ItemGroup")
from item in list.Elements(ns + "Reference")
/* where item.Element(ns + "HintPath") != null */
select new
{
CsProjFileName = fileName,
ReferenceInclude = item.Attribute("Include").Value,
RefType = (item.Element(ns + "HintPath") == null) ? "CompiledDLLInGac" : "CompiledDLL",
HintPath = (item.Element(ns + "HintPath") == null) ? string.Empty : item.Element(ns + "HintPath").Value
};
foreach (var v in list1)
{
Console.WriteLine(v.ToString());
}
//References "By Project"
var list2 = from list in xDoc.Descendants(ns + "ItemGroup")
from item in list.Elements(ns + "ProjectReference")
where
item.Element(ns + "Project") != null
select new
{
CsProjFileName = fileName,
ReferenceInclude = item.Attribute("Include").Value,
RefType = "ProjectReference",
ProjectGuid = item.Element(ns + "Project").Value
};
foreach (var v in list2)
{
Console.WriteLine(v.ToString());
}