Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am using c# code to browse project files i.e .csproj file using FileOpenDialog using the following code
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Project Files|*.csproj;";
if (dlg.ShowDialog() == DialogResult.OK)
{                
     string filePath = dlg.FileName;         
     Microsoft.Build.Evaluation.Project project = new 
                Microsoft.Build.Evaluation.Project(dlg.FileName);
}


Now I want to get the list of all the project references in the loaded project, but do not know how to do this.

I am thankful to any response in advance.

What I have tried:

I am exploring MSBuild API but could not get any thing useful.
Posted
Updated 21-May-19 11:03am

1 solution

At this point, what you can do is using the debugger to explore the content of the project variable: put a breakpoint on the line where you are initializing the project variable, and launch a debug session. Select a file in the dialog and press Open. The IDE should come back and wait for you to issue debug instructions. Press F10 to execute the project initialization. From here you will be able to watch all values stored in the Project object. There are a bunch of properties which are collections of values; references may be inside one of them.
You can ask further details if you have issues with the debugger.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900