Windows 驱动程序工具包 (WDK) 提供 MessageCompiler 任务,以便你可以在使用 MSBuild 生成驱动程序时运行 MC.exe 工具。 有关使用 MC.exe 的信息,请参阅 消息编译器 (MC.exe) 。
MSBuild 使用 MessageCompile 项发送 MessageCompiler 任务的参数。 MessageCompile 项访问项目文件中 mc.exe 的项元数据。
以下示例演示如何编辑 .vcxproj 文件中的元数据。
<ItemGroup>
    <MessageCompile Include="a.mc">
      <GenerateBaselineResource>true</GenerateBaselineResource>
      <BaselineResourcePath>c:\test\</BaselineResourcePath>
    </MessageCompile>
</ItemGroup>
以下示例演示命令行调用:
mc.exe –s "c:\test\" a.mc
在上面的示例中,MSBuild 使用 –s 开关对文件 a.mc 调用 mc.exe,因为元数据 GenerateBaselineResource 设置为 true。 此外,MSBuild 使用 BaselineResourcePath 元数据来指定 –s 开关的参数。
| MessageCompiler 任务参数 | 项元数据 | 工具开关 | 
|---|---|---|
| Sources 可选字符串参数。 指定要编译的清单文件的名称。 指定要编译的消息文件的名称。 | @ (MessageCompile) | <filename.man> <filename.mc> | 
| ANSIInputFile 指定输入文件为 ANSI (默认) 。 | % (MessageCompile.ANSIInputFile) | -a | 
| ANSIMessageInBinFile 指定 中的消息。BIN 文件应为 ANSI。 | % (MessageCompile.ANSIMessageInBinFile) | -A | 
| EnableDebugOutputPath 如果设置为 true,则启用 –x 开关。 | % (MessageCompile.EnableDebugOutputPath) | |
| DebugOutputPath 指定编译器将 .dbg C 包含文件放置到的文件夹。 .dbg 文件将消息 ID 映射到其符号名称。 | % (MessageCompile.DebugOutputPath) | -x<路径> | 
| EnableCallOutMacro 添加标注宏以在日志记录期间调用用户代码。 此开关对 C# 无效,将被忽略。 | % (MessageCompile.EnableCallOutMacro) | -co | 
| EventmanPath 指定 eventman.xsd 文件的路径。 | % (MessageCompile.EventmanPath) | -w<文件> | 
| GenerateBaselineResource 如果设置为 true,则启用 -s 开关。 | % (MessageCompile.GenerateBaselineResource) | |
| BaselineResourcePath 为每个提供程序生成二进制资源。 生成全局资源MCGenResource.BIN摘要。 | % (MessageCompile.BaselineResourcePath) | -s<路径> | 
| GenerateC#LoggingClass 生成 C# (基于 FX3.5 Eventing 类的托管) 日志记录类。 | % (MessageCompile.GenerateC#LoggingClass) | -cs<命名空间> | 
| GenerateC#StaticLoggingClass 生成静态 C# (基于 FX3.5 Eventing 类的托管) 日志记录类。 | % (MessageCompile.GenerateC#StaticLoggingClass) | -css<命名空间> | 
| GeneratedFilesBaseName 指定生成的文件的基名称。 默认值为输入文件的基名称。 | % (MessageCompile.GeneratedFilesBaseName) | -z<basename> | 
| GeneratedHeaderPath 如果设置为 true,则启用 -h 开关。 | % (MessageCompile.GeneratedHeaderPath) | |
| HeaderFilePath 指定创建 C 包含文件的位置的路径。 默认值为 。 | % (MessageCompile.HeaderFilePath) | -h<path> | 
| GeneratedRcAndMessagesPath 如果设置为 true,则启用 -r 开关。 | % (MessageCompile.GeneratedRcAndMessagesPath) | |
| RCFilePath 指定 RC 包含文件的路径及其包含的二进制消息资源文件。 默认值为 。 | % (MessageCompile.RCFilePath) | -r<path> | 
| GenerateKernelModeLoggingMacros 生成内核模式日志记录宏。 | % (MessageCompile.GenerateKernelModeLoggingMacros) | -公里 | 
| GenerateMOFFile 生成对生成的所有函数和宏的下层支持。 MOF 文件是从清单生成的。 MOF 文件放置在“-h”开关指定的位置。 | % (MessageCompile.GenerateMOFFile) | -Mof | 
| GenerateOLE2Header 生成 OLE2 头文件。 使用 HRESULT 定义而不是状态代码定义。 | % (MessageCompile.GenerateOLE2Header) | -o | 
| GenerateUserModeLoggingMacros 生成用户模式日志记录宏。 | % (MessageCompile.GenerateUserModeLoggingMacros) | -um | 
| HeaderExtension 指定头文件的扩展名 (1-3 个字符) 。 | % (MessageCompile.HeaderExtension) | -e<扩展> | 
| MaximumMessageLength 如果任何消息的大小超过 <长度> 字符,则生成警告。 | % (MessageCompile.MaximumMessageLength) | -m<长度> | 
| PrefixMacroName 定义应用于每个生成的日志记录宏的宏名称前缀。 默认值为“EventWrite”。 | % (MessageCompile PrefixMacroName) | -p<前缀> | 
| RemoveCharsFromSymbolName 定义在形成宏名称之前要删除的每个事件符号名称开头的文本。 默认值为 NULL。 | % (RemoveCharsFromSymbolName) | -P<前缀> | 
| SetCustomerbit 在整个消息 ID 中设置客户位。 | % (MessageCompile.SetCustomerbit) | -c | 
| TerminateMessageWithNull 终止消息表中具有 null 字符的所有字符串。 | % (MessageCompile.TerminateMessageWithNull) | -n | 
| UnicodeInputFile 输入文件为 Unicode。 | % (MessageCompile.UnicodeInputFile) | -u | 
| UnicodeMessageInBinFile 中的消息。BIN 文件应为 unicode (默认) 。 | % (MessageCompile.UnicodeMessageInBinFile) | -U | 
| UseBaseNameOfInput 指定 。为了保持唯一性,BIN 文件名应包含 .mc 文件名。 | % (MessageCompile。UseBaseNameOfInput) | -b | 
| UseDecimalValues 以十进制形式指定头文件中的 FACILTY 和 SEVERITY 值。 最初将标头中的消息值设置为十进制。 | % (MessageCompile.UseDecimalValues) | -d | 
| ValidateAgainstBaselineResource 如果此值设置为 true,则生成 -t 开关。 | % (MessageCompile.ValidateAgainstBaselineResource) | |
| BaselinePath 针对基线资源进行验证。 | % (MessageCompile.BaselinePath) | -t<路径> | 
| 详细 指定详细输出。 | % (MessageCompile.Verbose) | -v | 
| WinmetaPath 指定 winmeta.xml 文件的路径。 | % (MessageCompile.WinmetaPath) | -W<文件> |