从解决方案sln的所有csproj项目中阅读参考文献列表(以编程方式) [英] Reading the list of References from All csproj project of solution sln (programmatically)

查看:75
本文介绍了从解决方案sln的所有csproj项目中阅读参考文献列表(以编程方式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有解决方案sln,其中有许多csproj项目。

I have solution sln, that has many csproj projects.

有人知道一种以编程方式读取sln文件VS2008中所有csproj项目的引用列表的方法吗?

anyone know a way to programmatically read the list of References of all csproj projects in a VS2008 of sln file?

推荐答案

csproj文件只是XML文件。您可以为此使用.NET框架中的XDocument。我已经在VS2010中做到了,但是在VS2008中,标签几乎是相同的。

csproj files are just XML files. You can use XDocument from the .NET framework for this. I've done it for VS2010, but in VS2008 the tags are almost the same.

VS2010的示例,您必须验证标签和命名空间:

Example for VS2010, you have to verify the tags and namespace:

XElement projectNode = XElement.Load(fileName);
XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
var referenceNodes = projectNode.Descendants(ns + "ItemGroup").Descendants(ns + "Reference")

您可能还想检查ProjectReference标记。希望有帮助。

You might also wanna check for the ProjectReference tag. Hope that helps.

这篇关于从解决方案sln的所有csproj项目中阅读参考文献列表(以编程方式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆