Kiq*_*net 5 .net scripting projects-and-solutions reference csproj
我有解决方案sln,它有许多csproj项目.
有谁知道一种方法以编程方式读取sln文件的VS2008中所有csproj项目的引用列表?
csproj 文件只是 XML 文件。为此,您可以使用 .NET 框架中的 XDocument。我已经在VS2010中完成了,但是在VS2008中标签几乎是相同的。
以 VS2010 为例,您必须验证标签和命名空间:
XElement projectNode = XElement.Load(fileName);
XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
var referenceNodes = projectNode.Descendants(ns + "ItemGroup").Descendants(ns + "Reference")
Run Code Online (Sandbox Code Playgroud)
您可能还想检查 ProjectReference 标签。希望有帮助。