This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here
Stops a build and logs an error based on an evaluated conditional statement.
The folowing table describes the parameters of the
The error code to associate with the error.
The name of the file that contains the error. If no file name is provided, the file containing the Error task will be used.
The Help keyword to associate with the error.
The error text that MSBuild logs if the
Error task allows MSBuild projects issue error text to loggers and stop build execution.
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 Obtaining Build Logs.
In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.
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
<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>