Project.PropertyGroups Property

Definition

Read-only accessor for the raw property groups of this project. This is essentially a reflection of the data in the XML for this project's properties as well as any <Import>'d projects.

C#
public Microsoft.Build.BuildEngine.BuildPropertyGroupCollection PropertyGroups { get; }

Property Value

A BuildPropertyGroupCollection containing the property groups specified in the project.

Examples

The following example creates a Project object and uses the BuildItem, BuildPropertyBuildItemGroup, and BuildPropertyGroup classes to list all the items and properties in the project.

C#
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.BuildEngine;

namespace ListItemAndPropertiesCS
{
    class Program
    {
        static void Main(string[] args)
        {
            // SET THIS TO POINT TO THE RIGHT LOCATION
            Engine.GlobalEngine.BinPath = @"C:\Windows\Microsoft.NET\Framework\v2.0.xxxxx";

            // Create a new empty project
            Project project = new Project();

            // Load a project
            project.Load(@"c:\temp\validate.proj");

            Console.WriteLine("Project Properties");
            Console.WriteLine("----------------------------------");

            // Iterate through the various property groups and subsequently
            // through the various properties
            foreach (BuildPropertyGroup propertyGroup in project.PropertyGroups)
            {
                foreach (BuildProperty prop in propertyGroup)
                {
                    Console.WriteLine("{0}:{1}", prop.Name, prop.Value);
                }
            }

            Console.WriteLine();
            Console.WriteLine("Project Items");
            Console.WriteLine("----------------------------------");

            // Iterate through the various itemgroups
            // and subsequently through the items
            foreach (BuildItemGroup itemGroup in project.ItemGroups)
            {
                foreach (BuildItem item in itemGroup)
                {
                    Console.WriteLine("{0}:{1}", item.Name, item.Include);
                }
            }
        }
    }
}

Remarks

The BuildPropertyGroupCollection returned by this property contains the property groups in this project and all imported projects.

Applies to

Producto Versiones
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1