Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
MSBuild Reference
 Error Task
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework General Reference
Error Task

Stops a build and logs an error based on an evaluated conditional statement.

The folowing table describes the parameters of the Error task.

Parameter

Description

Code

Optional String parameter.

The error code to associate with the error.

HelpKeyword

Optional String parameter.

The Help keyword to associate with the error.

Text

Optional String parameter.

The error text that MSBuild logs if the Condition parameter evaluates to true.

The Error task allows MSBuild projects issue error text to loggers and stop build execution.

If the Condition parameter evaluates to true, the build is stopped, and an error is logged. If a Condition parameter does not exist, the error is logged and build execution stops. For more information on logging, see Overview of Logging in MSBuild.

The following code example verifies that all required properties are set. If they are not set, the project raises an error event, and logs the value of the Text parameter of the Error task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="ValidateCommandLine">
        <Error
            Text=" The 0 property must be set on the command line."
            Condition="'$(0)' == ''" />
        <Error
            Text="The FREEBUILD property must be set on the command line."
            Condition="'$(FREEBUILD)' == ''" />
    </Target>
    ...
</Project>
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker