다음을 통해 공유


Output Element (MSBuild)

Stores task output values in items and properties.

<Project>
   <Target>
     <Task>
       <Output>

<Output TaskParameter="Parameter"
    PropertyName="PropertyName" 
    Condition = "'String A' == 'String B'" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

TaskParameter

Required attribute.

The name of the task's output parameter.

PropertyName

Either the PropertyName or ItemName attribute is required.

The property that receives the task's output parameter value. Your project can then reference the property with the $(PropertyName) syntax. This property name can either be a new property name or a name that is already defined in the project.

This attribute cannot be used if ItemName is also being used.

ItemName

Either the PropertyName or ItemName attribute is required.

The item that receives the task's output parameter value. Your project can then reference the item with the @(ItemName) syntax. The item name can either be a new item name or a name that is already defined in the project.

This attribute cannot be used if PropertyName is also being used.

Condition

Optional attribute.

Condition to be evaluated. For more information, see MSBuild Conditions.

Child Elements

None.

Parent Elements

Element

Description

Task

Creates and executes an instance of an MSBuild task.

Example

The following code example shows the Csc task being executed inside of a Target element. The items and properties passed to the task parameters are declared outside of the scope of this example. The value from the output parameter OutputAssembly is stored in the FinalAssemblyName item, and the value from the output parameter BuildSucceeded is stored in the BuildWorked property. For more information, see MSBuild Tasks.

<Target Name="Compile" DependsOnTargets="Resources">
    <Csc  Sources="@(CSFile)"
            TargetType="library"
            Resources="@(CompiledResources)"
            EmitDebugInformation="$(includeDebugInformation)"
            References="@(Reference)"
            DebugType="$(debuggingType)"
            OutputAssembly="$(builtdir)\$(MSBuildProjectName).dll" >
        <Output TaskParameter="OutputAssembly"
                  ItemName="FinalAssemblyName" />
        <Output TaskParameter="BuildSucceeded"
                  PropertyName="BuildWorked" />
    </Csc>
</Target>

See Also

Concepts

MSBuild Project File Schema Reference

MSBuild Tasks