I have a build task that I am working on using msbuild. Within the task I have several targets, some of which perform preparation work.
When I execute "msbuild myEvent.msbuild /t:event3" the event runs. The first event in the DependsOnTargets executes but the second event in the list of targets does not. Example
<!-- only event1 will fire -->
<Target Name="event3" DependsOnTargets="event1; event2">
<Task TaskAction="myAction3"/>
</Target>
<Target Name="event1" DependsOnTargets="event4">
... do tasks here
</Target>
<Target Name="event2" >
... do tasks here
</Target>
<Target Name="event4" >
</Target>
I have attempted to modify this by eliminating the space in the DependsOnTargets values. I ensure that I have semicolon separated values. I have tried using BeforeTargets and AfterTargets without success.
My msbuild code targets ToolsVersion 4.0.
Is there something that I am missing with how DependsOnTargets works?
EDIT
- I think I figured out my problem. MSBuild does not allow me to execute the same target more than once.
- In this case I have to do the following
- start a database service
- drop databases
- stop the service
- Extract some database files from a zip file
- start the database service
- Attach databases
- Perform further action on databases ...
- The first start database service will execute as well as drop databases and stopping the service. The next call to start the database service fails.