Created
April 16, 2015 09:47
-
-
Save sayedihashimi/6c352cb78591f7abe04f to your computer and use it in GitHub Desktop.
This file will disable pre and post build events globally in MSBuild and Visual Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- | |
You can use this file to disable pre and post events globally across both MSBuild and Visual Studio. | |
To use this file, you have two options. | |
1. Save this file as C:\Program Files (x86)\MSBuild\v14.0\Custom.After.Microsoft.Common.targets | |
Or whatever the value of the MSBuild property $(CustomAfterMicrosoftCommonTargets). | |
2. Save this file to a random location, lets say C:\temp\msbuild\nopreorpostevents.targets, | |
then set the CustomAfterMicrosoftCommonTargets env var to point to that file. Then start Visual Studio. | |
You can set this from a PowerShell prompt (cmd prompt as well of course) and then start Visual Studio | |
from that prompt to apply the environment variable. | |
```powershell | |
$env:CustomAfterMicrosoftCommonTargets='C:\temp\msbuild\nopreorpostevents.targets' | |
"${env:ProgramFiles(x86)}\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" | |
``` | |
You can also call MSBuild from the prompt and it will honor that property as well. | |
If you're calling MSBuild from PowerShell see psbuild https://github.com/ligershark/psbuild. | |
--> | |
<!-- | |
Add the target that will override the property to the top of the build targets | |
--> | |
<PropertyGroup> | |
<BuildDependsOn> | |
DisablePreAndPostEvents; | |
$(BuildDependsOn); | |
</BuildDependsOn> | |
</PropertyGroup> | |
<Target Name="DisablePreAndPostEvents"> | |
<Message Text="Removing pre and post events (via $(MSBuildThisFileFullPath))" /> | |
<!-- | |
Since this is inside a target it will overwrite any previous value even global ones | |
--> | |
<PropertyGroup> | |
<PreBuildEvent></PreBuildEvent> | |
<PostBuildEvent></PostBuildEvent> | |
</PropertyGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment