A few days ago, I came across a strange issue in the standard nant mkiisdir task. Trying to create a virtual directory spit out the following stack trace.
Error creating virtual directory 'App' on 'localhost:80' (website: Default Web Site).:
NAnt.Core.BuildException:
Error creating virtual directory 'App' on 'localhost:80' (website: Default Web Site). ---> System.IO.DirectoryNotFoundException: The system cannot find the path specified.
at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.SetInfo()
at System.DirectoryServices.DirectoryEntry.CommitChanges()
at NAnt.Contrib.Tasks.Web.CreateVirtualDirectory.GetOrMakeNode(String basePath, String relPath, String schemaClassName)
at NAnt.Contrib.Tasks.Web.CreateVirtualDirectory.ExecuteTask()
--- End of inner exception stack trace ---
at NAnt.Contrib.Tasks.Web.CreateVirtualDirectory.ExecuteTask()
at NAnt.Core.Task.Execute()
at Macrodef.MacroDefInvocation.ExecuteInvocationTasks(XmlNode invocationTasks)
at Macrodef.MacroDefInvocation.Execute()
at Macrodef.MacroDefTask.Invoke(XmlNode xml, Task task)
at Macrodef.MacroDefTask.ExecuteTask(String name, XmlNode xml, Task task)
at nant984559eed3f243d4a16c2f92ed27e81c.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Contrib.Tasks.NestedTaskContainer.ExecuteChildTasks()
at NAnt.Contrib.Tasks.NestedTaskContainer.Execute()
at NAnt.Contrib.Tasks.ChooseTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()
Per code in NantContrib (and per the stack trace given), we are using the ADSI interface of IIS to create virtual directories. I checked for prerequisites to run the task. I was running as an admin. UAC was disabled on the system. IIS 6 compatibility was installed (it was a win 2008 server running IIS7). I was able to create the virtual directory manually from the inetmgr console. I looked on the web for other possible causes. None of the links proved useful.
After a lot of "Google" research and head banging, I happened to take a look at the metabase of the IIS. The metabase is a bunch of configurations present in the C:\windows\System32\inetsrv\config directory. The applicationHost.config had some random entries corresponding to "App", and a mysterious app pool named "@app-pool-name@". These were never being removed from the config when I deleted these entries from the console. Deleted this and ran the task again. This time, the task ran like a charm.