Created
October 13, 2022 18:38
-
-
Save danuw/fddc7dcc0a0963f876dc471961060127 to your computer and use it in GitHub Desktop.
List project dependencies (not recursive yet)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Xml; | |
// Set up a set of projects using https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference | |
var projectPath = "../Project1/Project1.csproj"; | |
Console.WriteLine($"List of Project dependencies for {projectPath}"); | |
var listOfProjectsChecked = new List<string>(); | |
var listOfDependencies = new List<string>(); | |
XmlDocument doc = new XmlDocument(); | |
doc.Load(projectPath); | |
XmlNodeList elemList = doc.GetElementsByTagName("ProjectReference"); | |
Console.WriteLine($"There are '{elemList.Count}' dependencies:"); | |
for (int i = 0; i < elemList.Count; i++) | |
{ | |
string attrVal = elemList[i].Attributes["Include"].Value; | |
listOfProjectsChecked.Add(attrVal); | |
} | |
listOfProjectsChecked.Distinct().ToList().ForEach(i => Console.WriteLine(i)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment