다음을 통해 공유


Custom Build providers for C# using MSBuild

Custom Build providers have been the prerogative of ASP.NET 2.0 developers so far. ASP.NET has a far superior compile model compared to the traditional WinForms apps. You can register a build provider for an extension and when you add a file with that extension, your custom build provider's GenerateCode will be called. The best part of this model is that since this code generation and its compilation are happening at design time, you will have access to the objects generated with Intellisense as well - neat.

Dino Esposito uses MSBuild custom tasks to simulate this behaviour for the not-so-lucky non ASP.NET developers. A custom task would be the build provider and then he wires up the project file to call a target which will invoke your task and then add the generated file to the project. Not as breezy as with ASP .NET but once you set up you can also have some jaw-dropping!