nant/nantcontrib — pull request #27 by dguder (2013-04-01 22:23:10+00:00)
Title: VB6 Task failing when "ResFile32" present in .vbp

When using tasks, the first build works well, however any builds after that fails with the following exception.

Build Error: NAnt.Core.BuildException
Error creating FileSet.
at NAnt.Core.Types.FileSet.Scan()
at NAnt.Core.Types.FileSet.get_FileNames()
at NAnt.Contrib.Tasks.Vb6Task.ProjectNeedsCompiling(String projectFile)
at NAnt.Contrib.Tasks.Vb6Task.NeedsCompiling()
at NAnt.Contrib.Tasks.Vb6Task.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()

After adding some logging to both NAnt and NAntContrib, i found out that if my project (.vbp) contains an ResFile32 entry, it is automatically decorated with double-quotes.
The ParseProjectFile() function inside of Vb6Task isn't aware of that and it returns this entry still decorated with the double-quotes.
So it fails when it gets to line 371 : "fileName = FileSet.FindMoreRecentLastWriteTime(references.FileNames, outputFileInfo.LastWriteTime);"

Because references.FileNames gets called with a list that contains many valid entries, but one that is decorated with double-quotes.

Stack trace from within NAnt looks like this :
Error creating FileSet. ---> System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.Combine(String path1, String path2)
at NAnt.Core.DirectoryScanner.CleanPath(String baseDirectory, String nantPath)
at NAnt.Core.DirectoryScanner.ParseSearchDirectoryAndPattern(Boolean isInclude, String originalNAntPattern, String& searchDirectory, Boolean& recursive, Boolean& isRegex, String& regexPattern)
at NAnt.Core.DirectoryScanner.ConvertPatterns(StringCollection nantPatterns, ArrayList regexPatterns, StringCollection nonRegexFiles, Boolean addSearchDirectories)
at NAnt.Core.DirectoryScanner.Scan()
at NAnt.Core.Types.FileSet.Scan()
--- End of inner exception stack trace ---
at NAnt.Core.Types.FileSet.Scan()
at NAnt.Core.Types.FileSet.get_FileNames()
at NAnt.Contrib.Tasks.Vb6Task.ProjectNeedsCompiling(String projectFile)
at NAnt.Contrib.Tasks.Vb6Task.NeedsCompiling()
at NAnt.Contrib.Tasks.Vb6Task.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()

To temporary fix this issue in my build environement, i replaced line 519 of Vb6Task.cs with:
sources.Includes.Add(keyValue.Replace("\"",""));
This removes any double-quotes, which are not part of any valid filename anyways.
This doesn't seem like a proper long-term fix, but it's good enough for me in the short-term.

One thing i tried, to confirm that this isnt an issue with my single .vbp file, is i edited the vbp outside from a text editor to remove the double-quotes around the ResFiles32 entry, saved the file, opened it in the VB6 IDE, did absolutely no changes, closed the IDE. It asked if i wanted to save the .vbp file (suspicious...), i did save it and reopened the vbp in the text editor. As i tought, the double-quotes are back.

Hopefully this issue submission is detailled enough, should you want a sample .vbp file with the issue, i can provide one.