Determine if MSBuild CoreCompile will run and call custom target

后端 未结 4 1967
旧巷少年郎
旧巷少年郎 2020-12-08 23:55

This seems like an obvious thing to want to do but I have pulled most of my hair out trying to find any examples on the web or do it myself.

I have a c# solution wit

4条回答
  •  感情败类
    2020-12-09 00:50

    In the end the solution was a combination of Sayed Ibrahim Hashimi's blog entry and information from the MSDN Forum entry 'Execute target when (core)compile will execute'.

    I basically took Sayed's injection method to get my target to run 'extend-corecompile.proj' on all projects without having to edit each proj file but replaced it's contents with an override for 'CoreCompileDependsOn' that points to a custom target that adopts the same inputs and outputs as the 'CoreCompile' target. The end result is a target that only runs when 'CoreCompile' will run while being centrally managed in the build script.

    Thanks to all for their input and here is the skeleton code I used in 'extend-corecompile.proj':

    
    
        
            $(TargetsTriggeredByCompilation);
            CustomPostTarget
        
    
    
    
    
        
            $(CoreCompileDependsOn);
            CustomPreTarget
        
    
    
    
    
        
    
    
    
    
        
    
    

    Not sure what will happen if CoreCompile fails, does it still call our target? I guess in time we'll find out :)

提交回复
热议问题