Compartilhar via


Output element (MSBuild)

Stores task output values in items and properties.

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

Syntax

<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. When the item name is an existing item, the output parameter values are added to the existing item.

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

Condition to be evaluated. For more information, see 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 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