I’m trying to write a custom NAnt task that does some file-based operations. One of the things that would be incredibly useful would be the ability to run the <expandproperties> filter on one of the input files.
In the interest of keeping the task suitably generic, I simply want to enable support for the <filterchain> element (similar to how the <copy> task works).
I’ve been using the source for the <copy> task to guide me, however I keep on running into methods that are internal when it comes to writing the tasks. I know I can use reflection to break encapsulation, but I’m reluctant to do this.
Does anyone know of any useful articles, or have any experience with this?
I started going down the road of creating a private Filter subclass that took a TextReader (basically re-creating the PhysicalTextReader inside the NAnt source). However I realised that, actually, there was a much easier way of reading a file through a filter chain:
Then you can use this exactly as you would expect: