Is there a way to conditionally run Visual Studio Post Build build steps

What we are looking for is this: when compiling the same configuration, for example Release | Win32, there is a way to do only postbuild steps. For example, if I follow all the steps after the build on the dev machine, or if I'm on the build server, then do not do them. Or is this the only way to achieve this by performing a new configuration?

Commentators: Thanks for the ideas, we donโ€™t want to use scripts, as they will be one more thing to support, and there will be a lot of headache for MSI proj files at this stage. Thanks for trying.

+6
visual studio
source share
4 answers

You can use environment variables in a post build script. Something like that:

if NOT %ComputerName% == DEVMACHINENAME GOTO end c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ngen "$(TargetPath)" :end 
+14
source share

If you want to hack MSBuild itself (. * Proj files are, in fact, only MSBuild scripts), you can run machine-specific steps after assembly: http://flimflan.com/blog/MachineSpecificTasksWithMSBuild.aspx

"This takes advantage of the fact that all environment variables are immediately available as properties in the MSBuild script, and that all the Windows computers I've been working with recently have a set of COMPUTERNAME environment variables."

+1
source share

If you don't like having a separate build configuration (which I think makes sense), you can, for example, define an environment variable on your build server, which you can check in your post-build script.

0
source share

Is it possible to implement post-build steps as an external script that always runs, but has logic for conditionally executing the necessary steps?

0
source share

All Articles