Proper use of msbuild inputs and outputs with Targets
Asked Answered
S

0

8

We have an in house compiler and linker tool that we're trying to make MSBUILD compatible (i.e. proper behavior in build/incremental builds/rebuild/clean scenarios)

In the first step we actually call CL task to preprocess our files. The issue is I can't seem to figure out how to set up the tasks properly to do that so it detects if the output is deleted or if one of the inputs is modified.

Second step is call our Compiler with it's proper parameters.

Third step is to call our Linker with it's proper parameters.

I think once step one works making step two and three will be simple; I'm stuck on step one. Example code below. The main MFT contains "#includes" which reference all the other MFT files named in _MFTFiles - so we only need to process the main file; but we need to monitor them all so if we change them incremental builds work properly. If anyone has any idea I'd love to hear it. I have the MSBUILD book and of course scoured here but I don't see an example of what I'm trying to accomplish.

Thanks in advance.

<ItemGroup Label="_MainMFT">
    <MainMFT Include="MFTSystem.MFT"/>        
</ItemGroup>

<ItemGroup Label="_MFTFiles">
    <MFTFiles Include="MFTbject.MFT;DebuggerSupport.MFT;enumerations.MFT;collections.MFT;DataStream.MFT;Version.MFT"/>
</ItemGroup>


<Target Name="_PreprocessFiles" 
        BeforeTargets="Build" 
        DependsOnTargets=""
        Inputs="@(MFTFiles)" 
        Outputs="@(MFTFiles->'%(Filename).MFTpp')">

    <Message Text="PlatformToolsetVersion is $(PlatformToolsetVersion)" Importance="high"/>

    <CL Sources="@(MainMFT)" PreprocessorDefinitions="_DEBUG;EL_DIAG_ENABLED" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" PreprocessToFile="true" PreprocessOutputPath="$(ProjectDir)%(Filename).MFTpp" />
    <CL Sources="@(MainMFT)" PreprocessorDefinitions="" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" PreprocessToFile="true" PreprocessOutputPath="$(ProjectDir)%(Filename).MFTpp"/>
</Target>

<Target Name="_ObjectCompiler" AfterTargets="_PreprocessFiles;Build">
    <Message Text="Calling ObjectCompiler...." Importance="high"/>

</Target>

<Target Name="_ObjectLinker" AfterTargets="_ObjectCompiler;Link">
    <Message Text="Calling ObjectLinker...." Importance="high"/>

</Target>
Semang answered 10/7, 2016 at 17:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.