After a long search for a simple solution to this problem, I did not find it, and in the end I came up with my own solution that works, but may not be the best solution. However, I would like to share it with anyone else with the same problem so that you can at least have a working solution and hopefully save a lot of noise.
Recall what I wanted to do was run the command line tool after my project, but only if the assembly was updated (i.e. the timestamp has changed). I did not want to put this in the section after the assembly of each project, because I only wanted the post-assembly to happen on our build server (not in the development machines).
I did not find any way to do this externally in my main .proj file and ended up changing the section after building each .csproj file. However, I prefix it with an if condition something like this:
if '$(ExecuteCommand)' == 'true' command.exe
This means that the command will never be executed on the development machine, but when I call the assembly from my .proj file, I can set this flag to true as follows:
<PropertyGroup> <ExecuteCommand>true</ExecuteCommand> </PropertyGroup> <Target Name="YourTarget"> <MSBuild Projects="Path to project" Properties="ExecuteCommand=$(ExecuteCommand)" /> </Target>
As I said, I do not think that this is the most elegant solution, but it certainly works and will be sufficient for me at the moment. However, I will still be interested to know what the right way to achieve this is so that I can improve my script.
Thanks Alan
Alan spark
source share