ASP.NET Hosting

Code generation in Visual Studio: build providers, MSBuild tasks, custom tools

PageMethods generates a list of your page methods in an XML file at compile time. This metadata file is then used to generate code you can invoke through the MyPageMethods namespace.
The first version of PageMethods for Visual Studio 2005 supported the only web project model available at that time: the Web Site model. In this model, a custom build provider takes care of the XML file and generates .NET code.
The latest version of PageMethods supports the Web Application project model as well. But a web application being a "class library" - and not strictly a "Web Site" in Visual Studio 2005 terms - build providers cannot be used in this case. Two solutions were possible: create an MSBuild custom task or a Visual Studio custom tool. I chose the latest, as it is easily integrated within Visual Studio and it works with Visual Studio 2002/2003 as well. In fact, custom tools are automatically used for XSD or WSDF files for example.

If you want to learn more about this kind of features, I highly advise you to read Dino Esposito's article about custom build providers, custom MSBuild tasks,  and VS custom tools.

No Comments