BuildPropertyGroup 클래스

정의

BuildProperty 개체의 컬렉션을 나타냅니다.Represents a collection of BuildProperty objects.

public ref class BuildPropertyGroup : System::Collections::IEnumerable
public class BuildPropertyGroup : System.Collections.IEnumerable
type BuildPropertyGroup = class
    interface IEnumerable
Public Class BuildPropertyGroup
Implements IEnumerable
상속
BuildPropertyGroup
구현

예제

다음 예제에서는 한 Project 사용 하 여 개체를 LoadXml 프로젝트에 콘텐츠를 추가 하는 방법.The following example creates a Project object and uses the LoadXml method to add content to the project. 합니다 BuildProperty, BuildPropertyGroup, 및 BuildPropertyGroupCollection 클래스는 추가, 제거 및 프로젝트의 항목을 변경 하는 데 사용 됩니다.The BuildProperty, BuildPropertyGroup, and BuildPropertyGroupCollection classes are used to add, remove, and change items in the project.

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Build.BuildEngine;

namespace AddNewProperty
{
    class Program
    {
        /// <summary>
        /// This code demonstrates the use of the following methods:
        ///     Engine constructor
        ///     Project constructor
        ///     Project.LoadFromXml
        ///     Project.Xml
        ///     BuildPropertyGroupCollection.GetEnumerator
        ///     BuildPropertyGroup.GetEnumerator
        ///     BuildProperty.Name (get)
        ///     BuildProperty.Value (set)
        ///     BuildPropertyGroup.RemoveProperty
        ///     BuildPropertyGroup.AddNewProperty
        /// </summary>
        static void Main()
        {
            // Create a new Engine object.
            Engine engine = new Engine(Environment.CurrentDirectory);

            // Create a new Project object.
            Project project = new Project(engine);

            // Load the project with the following XML, which contains
            // two PropertyGroups.
            project.LoadXml(@"
                <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

                    <PropertyGroup>
                        <Optimize>true</Optimize>
                        <WarningLevel>4</WarningLevel>
                    </PropertyGroup>

                    <PropertyGroup>
                        <OutputPath>bin\debug\</OutputPath>
                        <RemoveThisPropertyPlease>1</RemoveThisPropertyPlease>
                    </PropertyGroup>

                </Project>
                ");

            // Iterate through each PropertyGroup in the Project.  There are two.
            foreach (BuildPropertyGroup pg in project.PropertyGroups)
            {
                BuildProperty propertyToRemove = null;

                // Iterate through each Property in the PropertyGroup.
                foreach (BuildProperty property in pg)
                {
                    // If the property's name is "RemoveThisPropertyPlease", then
                    // store a reference to this property in a local variable,
                    // so we can remove it later.
                    if (property.Name == "RemoveThisPropertyPlease")
                    {
                        propertyToRemove = property;
                    }

                    // If the property's name is "OutputPath", change its value
                    // from "bin\debug\" to "bin\release\".
                    if (property.Name == "OutputPath")
                    {
                        property.Value = @"bin\release\";
                    }
                }

                // Remove the property named "RemoveThisPropertyPlease" from the
                // PropertyGroup
                if (propertyToRemove != null)
                {
                    pg.RemoveProperty(propertyToRemove);
                }

                // For each PropertyGroup that we found, add to the end of it
                // a new property called "MyNewProperty".
                pg.AddNewProperty("MyNewProperty", "MyNewValue");
            }

            // The project now looks like this:
            //
            //     <?xml version="1.0" encoding="utf-16"?>
            //     <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
            //         <Optimize>true</Optimize>
            //         <WarningLevel>4</WarningLevel>
            //         <MyNewProperty>MyNewValue</MyNewProperty>
            //         <OutputPath>bin\release</OutputPath>
            //         <MyNewProperty>MyNewValue</MyNewProperty>
            Console.WriteLine(project.Xml);
        }
    }
}
Module Module1

    ''' <summary>
    ''' This code demonstrates the use of the following methods:
    '''     Engine constructor
    '''     Project constructor
    '''     Project.LoadFromXml
    '''     Project.Xml
    '''     BuildPropertyGroupCollection.GetEnumerator
    '''     BuildPropertyGroup.GetEnumerator
    '''     BuildProperty.Name (get)
    '''     BuildProperty.Value (set)
    '''     BuildPropertyGroup.RemoveProperty
    '''     BuildPropertyGroup.AddNewProperty
    ''' </summary>
    ''' <remarks></remarks>
    Sub Main()

        ' Create a new Engine object.
        Dim engine As New Engine(Environment.CurrentDirectory)

        ' Create a new Project object.
        Dim project As New Project(engine)

        ' Load the project with the following XML, which contains
        ' two PropertyGroups.
        project.LoadXml( _
            "<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>" & _
                "<PropertyGroup>" & _
                    "<Optimize>true</Optimize>" & _
                    "<WarningLevel>4</WarningLevel>" & _
                "</PropertyGroup>" & _
                "<PropertyGroup>" & _
                    "<OutputPath>bin\debug\</OutputPath>" & _
                    "<RemoveThisPropertyPlease>1</RemoveThisPropertyPlease>" & _
                "</PropertyGroup>" & _
            "</Project>")

        ' Iterate through each PropertyGroup in the Project.  There are two.
        For Each pg As BuildPropertyGroup In project.PropertyGroups

            Dim propertyToRemove As BuildProperty
            propertyToRemove = Nothing

            ' Iterate through each Property in the PropertyGroup.
            For Each buildProperty As BuildProperty In pg

                ' If the property's name is "RemoveThisPropertyPlease", then
                ' store a reference to this property in a local variable,
                ' so we can remove it later.
                If buildProperty.Name = "RemoveThisPropertyPlease" Then
                    propertyToRemove = buildProperty
                End If

                ' If the property's name is "OutputPath", change its value
                ' from "bin\debug\" to "bin\release\".
                If buildProperty.Name = "OutputPath" Then
                    buildProperty.Value = "bin\release\"
                End If

            Next

            ' Remove the property named "RemoveThisPropertyPlease" from the
            ' PropertyGroup
            If Not propertyToRemove Is Nothing Then
                pg.RemoveProperty(propertyToRemove)
            End If

            ' For each PropertyGroup that we found, add to the end of it
            ' a new property called "MyNewProperty".
            pg.AddNewProperty("MyNewProperty", "MyNewValue")

        Next

        '  The project now looks like this:
        ' 
        '      <?xml version="1.0" encoding="utf-16"?>
        '      <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        '          <Optimize>true</Optimize>
        '          <WarningLevel>4</WarningLevel>
        '          <MyNewProperty>MyNewValue</MyNewProperty>
        '          <OutputPath>bin\release</OutputPath>
        '          <MyNewProperty>MyNewValue</MyNewProperty>
        Console.WriteLine(project.Xml)

    End Sub

End Module

설명

BuildPropertyGroup 개체는 프로젝트 또는 가상 전역 속성 또는 환경 변수 속성 등의 속성을 컬렉션에서 요소를 나타낼 수 있습니다.A BuildPropertyGroup object can represent a element in the project, or a virtual collection of properties, such as global properties or environment variable properties.

생성자

BuildPropertyGroup()

BuildPropertyGroup 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the BuildPropertyGroup class.

BuildPropertyGroup(Project)

지정된 프로젝트에서 새 PropertyGroup 요소를 초기화합니다.Initializes a new PropertyGroup element in the specified project.

속성

Condition

속성 그룹의 Condition 특성 값을 가져오거나 설정합니다.Gets or sets the Condition attribute value of the property group.

Count

BuildPropertyBuildPropertyGroup 개체 수를 나타내는 값을 가져옵니다.Gets a value indicating the number of BuildProperty objects in the BuildPropertyGroup.

IsImported

속성 그룹을 프로젝트로 가져왔는지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the property group was imported into the project.

Item[String]

BuildPropertyBuildPropertyGroup 개체를 가져오거나 설정합니다.Gets or sets a BuildProperty object in this BuildPropertyGroup.

메서드

AddNewProperty(String, String)

지정한 BuildPropertyName를 갖는 새 ValueBuildPropertyGroup에 추가합니다.Adds a new BuildProperty with the specified Name and Value to the BuildPropertyGroup.

AddNewProperty(String, String, Boolean)

지정한 BuildPropertyName를 갖는 새 ValueBuildPropertyGroup에 추가합니다.Adds a new BuildProperty with the specified Name and Value to the BuildPropertyGroup.

Clear()

Condition에서 BuildProperty 속성 값과 모든 BuildPropertyGroup 개체를 제거합니다.Removes the Condition property value and all BuildProperty objects from the BuildPropertyGroup.

Clone(Boolean)

BuildPropertyGroup의 전체 또는 단순 복사본을 만듭니다.Creates a deep or shallow copy of the BuildPropertyGroup.

Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(다음에서 상속됨 Object)
GetEnumerator()

BuildPropertyGroup을 반복하는 열거자를 가져옵니다.Gets an enumerator that iterates through the BuildPropertyGroup.

GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
RemoveProperty(BuildProperty)

BuildProperty에서 지정된 BuildPropertyGroup을 제거합니다.Removes the specified BuildProperty from the BuildPropertyGroup.

RemoveProperty(String)

BuildProperty에서 지정한 Name을 갖는 BuildPropertyGroup를 제거합니다.Removes the BuildProperty with the specified Name from the BuildPropertyGroup.

SetImportedPropertyGroupCondition(String)

가져온 속성 그룹에 대한 조건을 설정합니다.Sets the condition for imported property groups. 변경 사항은 유지되지 않습니다.Changes are not persisted.

SetProperty(String, String)

지정한 Value을 갖는 BuildPropertyName를 설정합니다.Sets the Value of the BuildProperty with the specified Name.

SetProperty(String, String, Boolean)

지정한 Value을 갖는 BuildPropertyName를 설정합니다.Sets the Value of the BuildProperty with the specified Name.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(다음에서 상속됨 Object)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.Converts an IEnumerable to an IQueryable.

적용 대상