In my csproj, I am importing a very large heavily used targets file (which I am not allowed to break down as of now). This targets file however, sets up various target dependencies by using AfterTargets='Build'.
In the csproj where I import this large targets file, I want to remove some of the After build target dependencies. For example, say the following target gets imported:
<!-- This is in the large targets file -->
<Target Name="Target1" AfterTargets="Build">
</Target>
How do I remove Target1
from being executed After build in the csproj I am importing it in.
What is a good way to accomplish that?
You have to overwrite the target Target1
and then set an empty for its target that means you have removed the previous Target1
.
Although it still appear on the build log, it is empty with no operation. That is the only way. And if you want to make Target1
not appear, you have to delete it under the large targets file.
You should note that you must write the new Target1
after the previous one to make the new one overwrite the old one.
For an example,
<!-- This is in the large targets file -->
<Target Name="Target1" AfterTargets="Build"> // the old one
//do some larget opertion
</Target>
........
........
<Target Name="Target1"> // the new one and make it empty
</Target>