true
.
If no conditions are checked, all child tasks are executed.
If more than one attribute is used, they are &&'d. The first to fail stops the check.
The order of condition evaluation is, NAnt.Core.Tasks.IfTask.TargetNameExists
,
NAnt.Core.Tasks.IfTask.PropertyNameExists
, NAnt.Core.Tasks.IfTask.PropertyNameTrue
,
NAnt.Core.Tasks.IfTask.UpToDateFile
.
NAnt.Core.Tasks.IfTask.Test
attribute:
Function |
---|
NAnt.Core.Functions.PropertyFunctions.Exists(System.String) |
NAnt.Core.Functions.TargetFunctions.Exists(System.String) |
Parameters
Attribute | Type | Description | Required |
---|---|---|---|
comparefile | string |
The file to check against for the uptodate file.
Obsolete. Use
|
False |
propertyexists | string |
Used to test whether a property exists.
Obsolete. Use
|
False |
propertytrue | string |
Used to test whether a property is true.
Obsolete. Use
|
False |
targetexists | string |
Used to test whether a target exists.
Obsolete. Use
|
False |
test | string |
Used to test arbitrary boolean expression.
|
False |
uptodatefile | string |
The file to compare if uptodate.
Obsolete. Use
|
False |
failonerror | bool |
Determines if task failure stops the build, or is just reported.
The default is
true .
|
False |
if | bool |
If
true then the task will be executed; otherwise,
skipped. The default is true .
|
False |
unless | bool |
Opposite of
NAnt.Core.Task.IfDefined . If false
then the task will be executed; otherwise, skipped. The default is
false .
|
False |
verbose | bool |
Determines whether the task should report detailed build log messages.
The default is
false .
|
False |
Nested elements
<comparefiles>
The NAnt.Core.Types.FileSet
that contains the comparison files for
the NAnt.Core.Tasks.IfTask.UpToDateFile
(s) check.
</comparefiles>
<uptodatefiles>
The NAnt.Core.Types.FileSet
that contains the uptodate files for
the NAnt.Core.Tasks.IfTask.CompareFile
(s) check.
</uptodatefiles>
Examples
Tests the value of a property using expressions.
<if test="${build.configuration=='release'}">
<echo>Build release configuration</echo>
</if>
Tests the the output of a function.
<if test="${not file::exists(filename) or file::get-length(filename) = 0}">
<echo message="The version file ${filename} doesn't exist or is empty!" />
</if>
(Deprecated)
Check that a target exists.
<target name="myTarget" />
<if targetexists="myTarget">
<echo message="myTarget exists" />
</if>
(Deprecated)
Check existence of a property.
<if propertyexists="myProp">
<echo message="myProp Exists. Value='${myProp}'" />
</if>
(Deprecated)
Check that a property value is true.
<if propertytrue="myProp">
<echo message="myProp is true. Value='${myProp}'" />
</if>
(Deprecated)
Check that a property exists and is true
(uses multiple conditions).
<if propertyexists="myProp" propertytrue="myProp">
<echo message="myProp is '${myProp}'" />
</if>
which is the same as
<if propertyexists="myProp">
<if propertytrue="myProp">
<echo message="myProp is '${myProp}'" />
</if>
</if>
(Deprecated)
Check file dates. If myfile.dll
is uptodate,
then do stuff.
<if uptodatefile="myfile.dll" comparefile="myfile.cs">
<echo message="myfile.dll is newer/same-date as myfile.cs" />
</if>
or
<if uptodatefile="myfile.dll">
<comparefiles>
<include name="*.cs" />
</comparefiles>
<echo message="myfile.dll is newer/same-date as myfile.cs" />
</if>
or
<if>
<uptodatefiles>
<include name="myfile.dll" />
</uptodatefiles>
<comparefiles>
<include name="*.cs" />
</comparefiles>
<echo message="myfile.dll is newer/same-date as myfile.cs" />
</if>
Requirements
- Assembly
- NAnt
.Core .dll - Namespace
-
NAnt
.Core .Tasks