Previous | Index | Next 

[HOWTO] Modify project-level options in .NET programs

VB Migration Partner generates .NET projects with a set of “reasonable” options. For example, the output path of generated projects defaults to “bin\Debug\” and “bin\Release”, respectively in Debug and Release mode, and generate the XML documentation file. There is no specific pragma to directly modify these settings, however you can easily use one or more PostProcess pragmas to manipulate the .vbproj file.

For example, say that you want to disable the generation of XML documentation file for a specific project. All you need to do is adding the following pragma somewhere in your source code:

        '##  project:PostProcess "<DocumentationFile>.+</DocumentationFile>",
        <DocumentationFile></DocumentationFile>", True, True

Notice that the last argument is True, to ensure that the pragma is applied to source files other than *.vb or *.cs files. (In this specific case the pragma affects the .vbproj or .csproj file.)

By default, the .NET project generates the *.pdb file in Release mode. You can prevent this from happening by means of the following pragma:

        '##  project:PostProcess "<DebugType>pdbonly</DebugType>",
        "<DebugType>None</DebugType  >", True, True

Changing the output path for compiled programs is also simple, if you are familiar with regular expressions. Let’s say that you want to generate all executables in Debug mode in the folder c:\myexes\debug and all executable in Release mode in the folder c:\myexes\release. Here’s the pragma that does the trick:

        '## project:PostProcess "<OutputPath>bin\\(?<mod>Debug|Release)\\</OutputPath>",
        "<OutputPath>c:\\myexes\\${mod}\\</OutputPath>",  True, True

Notice that you have to double the backslash characters both in the first and in the second argument.

If you want to easily use these pragmas in multiple projects, store them in a VBMigrationPartner.pragmas file and copy the file to the folders where these projects resides.

 

Previous | Index | Next