New in 0.2.0.8: support for the Razor template engine. The .NET Macro Processor (NMP) is a general purpose text macro processor for .NET 4.0 that you use to generate text fragments for programming projects (C#, C++, VB …), build scripts, HTML or any other text based system. Be they simple or complex input is read from a source text file, processed by one of the NMP "hosts" and then output to one or more text files. NMP allows you to implement one macro, several macros or whole libraries of macros that allow you to transform the input. Macros can be implemented as "Text" macros, "Compiled" macros or "Object" macros. Macros are recognized as a sequence of characters "[_#,a-zA-Z0-9]" that form a name that is looked up in a dictionary. Once found a macro name is replaced by the contents of the macro itself. This replacement can be a simple insertion of text into the output document, text that has substitution performed on "$tokens" by macro arguments, property values from a .NET object, or text generated by compiled .NET code (C#, VB (etc.) either as compiled macros or methods on object macros). In addition to the standard macro recognizer there is also a regular expression recognizer that allows you to define one or more patterns to recognize pieces of text; the macro to be invoked for the recognized text can be a single macro for all recognized instances, or can dynamically selected from one of the sub expressions defined within the regex. NMP currently has three ways to digest and output the processed text: Visual Studio 2010 / Visual Studio 2010 Express Custom Tool Once you have NMP installed you create or add a file with the ".nmp" extension and Visual Studio will recognize that it needs to be processed by the "NetMacroProcessor" custom tool. You set the output file extension with the #setOutputExtension() macro, Visual Studio chooses where to place the file. Command Line Host This host requires that you pass it the name of an input file which is then processed and output to a second file with the file extension and/or path that you choose. MSBuild Task This host runs under MSBuild. You define the input file, output file and any control macros you want to pass to NMP in your build script. Using the functionality built into MSBuild you can specify a relative path to the NMP task, or pick the location of the Task out of the registery. Netmacros.net Website |