Hi, I'm hoping somebody on this list can help me ... I'm trying to write a custom NAnt task that combines other tasks. Basically, there's a number of tasks that need to be done in order to build one of my projects. Since I'm going to have quite a few projects, and don't particularly want a bunch of long, almost-identical, scripts, I'd like to combine those tasks into one custom task. Some of it really is custom, but there's also a number of tasks that already exist. Which of course means that I would like to call those other tasks from within my own task (i.e: from C#). Unfortunately, the documentation is of course all aimed at people calling them from NAnt script ...
 
Now, some of it I've been able to figure out. For example, the following performs the solution task (assuming strSolution, strOutputDir, and bDebug have all been properly set of course):
NAnt.VSNet.Tasks.SolutionTask taskSolution = new NAnt.VSNet.Tasks.SolutionTask();
taskSolution.Project = Project;
taskSolution.SolutionFile = new FileInfo(strSolution);
taskSolution.OutputDir = new DirectoryInfo(strOutputDir);
taskSolution.Configuration = (bDebug ? "Debug" : "Release");
taskSolution.Execute();
Now where I'm having a problem is the mkiisdir task ... I've tried the following code:
NAnt.Contrib.Tasks.Web.CreateVirtualDirectory taskWeb = new NAnt.Contrib.Tasks.Web.CreateVirtualDirectory();
taskWeb.Project = Project;
taskWeb.DirPath = new DirectoryInfo(strWebDir);
taskWeb.VirtualDirectory = strWebClass;
taskWeb.Execute();
However, when I try to run the build, I get an error message about "Object reference not set to an instance of an object". So what am I doing wrong? Is there something more I should be doing to initialize the task? The corresponding NAnt script works fine, so I know it's not my IIS setup ...
 
Thanks,
Glen.
 

Reply via email to