Warning Task

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Logs a warning during a build based on an evaluated conditional statement.

The folowing table describes the parameters of the Warning task.

ParameterDescription
CodeOptional String parameter.

The warning code to associate with the warning.
FileOptional String parameter.

Specifies the relevant file, if any. If no file is provided, the file containing the Warning task is used.
HelpKeywordOptional String parameter.

The Help keyword to associate with the warning.
TextOptional String parameter.

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

The Warning task allows MSBuild projects to check for the presence of a required configuration or property before proceeding with the next build step.

If the Condition parameter of the Warning task evaluates to true, the value of the Text parameter is logged and the build continues to execute. If a Condition parameter does not exisit, the warning text is logged. 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 checks for properties that are set on the command line. If there are no properties set, the project raises a warning event, and logs the value of the Text parameter of the Warning task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
    <Target Name="ValidateCommandLine">  
        <Warning  
            Text=" The 0 property was not set on the command line."  
            Condition="'$(0)' == ''" />  
        <Warning  
            Text=" The FREEBUILD property was not set on the command line."  
            Condition="'$(FREEBUILD)' == ''" />  
    </Target>  
    ...  
</Project>  

Obtaining Build Logs
Project File Schema Reference

Show: