Can you prevent MSBuild.exe from running Build Events?

后端 未结 9 1912
我在风中等你
我在风中等你 2020-12-08 00:11

I\'m building a number of projects via a script, and the occasional use of custom build events causes a great deal of difficulty for the build system. If it is possible, I\

9条回答
  •  爱一瞬间的悲伤
    2020-12-08 00:40

    What I would do is define a new .proj file, lets say C:\Data\SupressBuildEvents.proj and it would contain:

    
        
    
        
    
    

    Then you need to specify that these files get imported after Microsoft.Common.targets and you would do so by defining the well known property CustomAfterMicrosoftCommonTargets to the path of that file. So lets your build script is in a file named MyBuild.proj you would invoke it as:

    msbuild MyBuild.proj /p:CustomAfterMicrosoftCommonTargets="C:\Data\SupressBuildEvents.proj
    "
    

    This will cause MSBuild to import your file after the Microsoft.Common.targets file gets imported and it will override the PostBuildEvent and PreBuildEvent targets and make them do nothing.

    Now if your MyBuild.proj files uses the MSBuild task to build other targets then you should also pass them this property as follows:

    
        
            
        
    
        
            
        
    
    
    

    This is necessary because by design properties on the parent script are not passed to the builds executed by the MSBuild task.

提交回复
热议问题