Edit

MIDLRT and Windows Runtime components

Shows how to create metadata (.winmd) files that represent the API for custom Windows Runtime components.

Use the MIDLRT compiler to build metadata (.winmd) files for your custom Windows Runtime components.

When your metadata files are generated, you can compose them into a more efficient package by using the MDMERGE utility. For more info, see MDMERGE and metadata files.

Using MIDLRT is similar to using the MIDL compiler. Run MIDLRT from the command line using the following command:

midlrt <options> filename.idl

where <options> represents the command-line options you want to use, and Filename.idl is the name of the IDL file to compile.

The following list shows the command-line switches that MIDLRT.EXE uses.

/enum_class
/metadata_dir
/nomidl
/nomd
/ns_prefix
/winmd
/winrt

A complete listing of MIDLRT compiler switches and options is available when you use the MIDLRT compiler /help and /? switches. The switches are organized by categories. For more info, see the MIDL Command-Line Reference.

Include XML documentation files for IntelliSense

When you distribute Windows Runtime components as NuGet packages, include XML documentation files (.xml) alongside the corresponding metadata (.winmd) files. XML doc files provide API descriptions, parameter documentation, and code examples that development tools such as Visual Studio and Visual Studio Code use to display IntelliSense tooltips.

Without XML documentation files, IntelliSense shows only the type and member names from the .winmd metadata, without descriptions or usage guidance.

To include XML documentation:

  1. Add /// triple-slash documentation comments to your Windows Runtime component source files.
  2. Configure your build to generate XML documentation output. For C# projects, set the GenerateDocumentationFile property to true in your project file. For C++/CLI projects, use the /doc compiler option. For native C++/WinRT projects, generate documentation XML from your IDL or source comments using a separate documentation tool.
  3. In your NuGet package, place the .xml files in the same directory as the corresponding .winmd files so that consuming projects automatically pick up the documentation.

MDMERGE and metadata files