I need to write a custom task that print all the defined properties (the non-reserved ones). So in my C# code, I wanna access to the properties list of MSBuild engine and I don't know how. Please help.
A:
Using .NET 4 :
using Microsoft.Build.Evaluation;
using Microsoft.Build.Utilities;
namespace MSBuildTasks
{
public class GetAllProperties : Task
{
public override bool Execute()
{
Project project = new Project(BuildEngine.ProjectFileOfTaskNode);
foreach (ProjectProperty evaluatedProperty in project.AllEvaluatedProperties)
{
if (!evaluatedProperty.IsEnvironmentProperty &&
!evaluatedProperty.IsGlobalProperty &&
!evaluatedProperty.IsReservedProperty)
{
string name = evaluatedProperty.Name;
string value = evaluatedProperty.EvaluatedValue;
}
// Do your stuff
}
return true;
}
}
}
madgnome
2010-05-05 12:22:43