Does anyone know of a way to programmatically read the list of References in a VS2008 csproj file? MSBuild does not appear to support this functionality. I\'m trying to re
The XPath should be /Project/ItemGroup/Reference
, and you have forgot the namespace. I'd just use XLINQ - dealing with namespaces in XPathNavigator
is rather messy. So:
XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003";
XDocument projDefinition = XDocument.Load(fullProjectPath);
IEnumerable references = projDefinition
.Element(msbuild + "Project")
.Elements(msbuild + "ItemGroup")
.Elements(msbuild + "Reference")
.Select(refElem => refElem.Value);
foreach (string reference in references)
{
Console.WriteLine(reference);
}