Implementing Single-File Generators

Switch View :
ScriptFree
Visual Studio SDK
Implementing Single-File Generators

A custom tool — sometimes referred to as a single file generator — can be used to extend the Visual Basic and Visual C# project systems in Visual Studio. A custom tool is a COM component that implements the IVsSingleFileGenerator interface. Using this interface, a custom tool transforms a single input file into a single output file. The result of the transformation may be source code, or any other output that is useful. Two examples of custom tool-generated code files are code generated in response to changes in a visual designer and files generated using Web Services Description Language (WSDL).

When a custom tool is loaded, or the input file is saved, the project system calls the Generate method, and passes a reference to a IVsGeneratorProgress callback interface, whereby the tool can report its progress to the user.

The output file that the custom tool generates is added to the project with a dependency on the input file. The project system automatically determines the name of the output file, based on the string returned by the custom tool's implementation of DefaultExtension.

A custom tool must implement the IVsSingleFileGenerator interface. Optionally, custom tools support the IObjectWithSite interface to retrieve information from sources other than the input file. In any case, before you can use a custom tool, you must register it with the system or in the Visual Studio local registry. For more information on registering custom tools, see Registering Single File Generators.

See Also

Concepts

Community Content

Thomas Lee
Terrible, broken instructions, broken examples, broken concept
I have spend several days trying to follow these instructions without success. First major problem is that almost all the community generated examples have disappeared due to the way Microsoft aborted its gotdotnet.com site. So there are several 'how to guides' on the web but none have running code.

The MSDN code example does not work either. It claims it will run an experimental hive of Visual Studio. This does not work in VS2010. I have no way to know why VS2010 can't see the tool.

But most importantly, this is a STUPID, STUPID way to integrate developer tools. I can add a custom tool to my makefile just by giving the command line. Why can't I do the same in VS? Why force people to hack around with COM and the horrid, horrid mess of things that won't work and will not tell you why.

[tfl - 27 01 12] Hi - and thanks for your post. Community content is not the appropriate place for technical support queries. Instead,
you should visit the MSDN Forums at http://forums.microsoft.com/MSDN, where such posts are welcomed and where you stand a much
better chance of getting your query resolved. Sorry if that's not the answer you wanted to hear.