Temporarily disable build events in visual studio

Is there a way to temporarily disable events before and after assembly?

i.e. build without assembly events (which take a little time, but arent always critical to run)

At the moment, I have minification and a few more things, and I do not always need this.

+4
source share
4 answers

A substance like minimization is only relevant for the Release build. Therefore, you can skip this as follows:

if "$(ConfigurationName)" == "Debug" goto skip ; stuff here... :skip 

There are several other macros that you can use, click the "Edit" button and the "Macro →" button to see them. You can also check environment variables, use% varname%. But much harder to install.

+8
source

The easiest way to disable build events is to pass empty values:

 msbuild your.sln /p:PreBuildEvent=;PostBuildEvent= 
+10
source

I also played a little with msbuild foo.vcxproj /p:PreBuildEvent= /p:PostBuildEvent= , but this did not work for me, perhaps because I use my own details.

What I found to work was /p:PostBuildEventUseInBuild=false

+6
source

Check the post build event settings. On the Assembly Events tab, change the Execute Assembly Event After Assembly event to When the assembly project is updated. Post build events will only be executed when the build assembly is updated.

OR

Use the MSBuild command to create your solution (this is useful for projects with multiple solutions). Create the file "DisableBuildEvents.msbuild" on your PC. DisableBuildEvents.msbuild :

 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="PostBuildEvent"/> <Target Name="PreBuildEvent" /> </Project> 

Run MsBuild using the CustomAfterMicrosoftCommonTargets property specified on the command line:

 MSBuild.exe YourSolution.sln /t:Build p:CustomAfterMicrosoftCommonTargets="c:\DisableBuildEvents.msbuild" 

Note. The value of CustomAfterMicrosoftCommonTargets must be the fully qualified path name.

+3
source

Source: https://habr.com/ru/post/1395046/


All Articles