I have a Visual Studio 2015 solution that builds 10 projects. In each project there are a pre and post build event to call ant to resolve and publish the code. These events should be triggered before and after every project build, so moving the events to the solution isn't going to work.
Each of the projects should also be capable of building from the command line using ant. When it builds from the command line the events are triggered, but it would be preferable if they weren't.
Does anyone know if there is there a way of VS/MSBuild determining if it is being triggered from within the GUI or from the command line?
I am not sure that you can do this in the PostBuildEvent, but you can use the AfterBuild target and add a condition like this:
<Target Name="AfterBuild">
<Exec Command="SOME_COMMAND" Condition=" '$(BuildingInsideVisualStudio)' == 'true' " />
</Target>
You will need to edit the project file by hand in order to do this, as the project properties does not let you control this.