MSBuild Programatically get property values from a project in a .sln file.
I can open a solution file and iterate through all of the projects in a solution:
SolutionFile sf = SolutionFile.Parse(fileName);
LogText($"Solution {fileName} file loaded");
var projects = sf.ProjectsInOrder;
foreach (var project in projects)
{
LogText($"Project: \"{project.ProjectName}\" Type: {project.ProjectType}");
}
I would like to be able to get all of the properties for one projects in the solution.
The following fails:
ProjectCollection pc = new ProjectCollection();
Project project = pc.LoadProject(fileName,null);
var properties = project.Properties;
foreach (var property in properties)
{
LogText($"Property: \"{property.Name}\" Value: {property.UnevaluatedValue}");
}
Clearly something within MSBuild is able to get this information to build the solution, how can I get this information programatically?
Side note: the property manager in Visual Studio can show these values for C++ source files, but there appears to be nothing similar for C#.