2016-02-27 52 views
0

如何以正確的方式使用mc.exe進行編譯。目前我有一個構建步驟,運行相關的命令,但看着developer networkmsbuild中的MC.exe

似乎有更好的方法。

我不是msbuild的專家,所以請原諒這個問題有多容易。谷歌搜索顯示沒有幫助

<Project 
    DefaultTargets="Build" 
    ToolsVersion="14.0" 
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

    <ItemGroup> 
    <Filter Include="Message Source Files"> 
     <Extensions>mc;</Extensions> 
     <UniqueIdentifier>{B796B525-44D3-4260-8C76-705DBADA1043}</UniqueIdentifier> 
    </Filter> 
    </ItemGroup> 

    <ItemGroup> 
    <MessageCompile Include="a.mc"> 
     <GenerateBaselineResource>true</GenerateBaselineResource> 
    </MessageCompile> 
    </ItemGroup> 

    <Target Name="Build"> 
    <DontKnowWhatGoesHere Sources="@(MessageCompile)"/> 
    </Target> 
</Project> 

回答

0

的MSBuild構建一般通過.targets文件,這些文件必須包含在項目擴展,它們擴展現有的構建理線。 The WDK tasks for MSBuild頁面確認:

這些命令行工具需要作爲任務(包含在目標中)暴露給MSBuild,以便它們可以在構建過程中運行。

的WDK MSDN頁面也有Windows driver targets幫助頁面:

的WindowsDriver.Common.targets,WindowsDriver.masm.targets和WindowsDriver.arm.targets文件提供了一個必要的目標建立一個驅動程序。

快速的grep在我C:\Program Files (x86)\Windows Kits\10\build目錄顯示,MessageCompile目標(實際處理MessageCompile項目的步驟)在build\WindowsDriver.Common.targets文件中定義。

importing後在你的項目目標,你可以做以下之一:

<Import 
    Project="C:\Program Files (x86)\Windows Kits\10\build\build\WindowsDriver.Common.targets" /> 


<!-- Option A: --> 
<Target Name="Build" DependsOnTargets="MessageCompile"> 
    <!-- no need to do anything, the dependency target should do the work --> 
</Target> 


<!-- Option B: --> 
<Target Name="Build" DependsOnTargets="MessageCompile"> 
    <!-- Use the Mc task which is the actual wrapper around the .exe, 
     see the .common.targets file for the list of all parameters --> 
    <Mc 
    Sources       ="@(MessageCompile)" 
    ToolExe       ="$(MessageCompileToolExe)" 
    ToolPath      ="$(MessageCompileToolPath)" 
    Generated 
    /> 
</Target>