문제

My custom NAnt task relies on a certain fileset. It is considered to be defined by the time the task executes. I'd like to make sure fileset was defined before using it. I'm thinking of something similar to property::exists('property').

I failed to find the appropriate function. Is it possible with NAnt (or NAntContrib) out of the box?

도움이 되었습니까?

해결책

Generally, tasks should not depend on filesets or properties. Instead, they should take explicit parameters. An existing fileset can be reused using refid, so there's no redeclaration resulting from this. Example syntax:

<myTask><filesetParameter refid="compileUs"/><myTask>

If the referenced fileset is not defined, NAnt will throw an exception - this is proper (expected) behaviour, as the build cannot continue at this point.

Inside your task, the property would be defined as follows:

[TaskName("myTask")]
public class MyTask : Task
{
  [TaskAttribute("filesetParameter", Required = true)]
  public FileSet FilesetParamter
  { get; set; }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top