*rubbing eyes* in MSBuild, what is the difference between DependsOnTargets and AfterTargets? Isn't that the same thing?
@sundew OK. In that case, is BeforeTargets different from DependsOnTargets
So I feel like this has happened to me nine times, in three different build systems, and I'm so tired.
We have an MSBuild project. It has targets A,B,C,D. Target D has an AfterTargets="A;B;C" in its xml.
When we run the project, we visibly see in the output window that the targets run in the order C;D;A;B. Moreover, the output of D is incorrect, as if D had been run without A and B having run first.
Why. Why. Why. Why. Why.
How do I convince MSBuild to do what I tell it to.
Related questions which I do not expect you to have an answer to.
1. Is this relevant? I think no, because it relates to MSBuild being told to build multiple project files in parallel, and our current problem concerns targets run potentially in parallel?
https://github.com/dotnet/msbuild/issues/11784
2. There's a <ZipDirectory> task in MSBuild. We in fact want our MSBuild to create a zip. But we want a 0-compression zip, which ZipDirectory lacks as an option.
How would you attack this problem? Must work on WIndows
*rubbing eyes* I stated this indistinctly.
There is a target CoreCompile. dotnet.exe runs this automatically.
We have our own targets, A, B, C, D. A, B and C are listed as AfterTarget="CoreCompile". D is listed as AfterTarget "A,B,C".
At this exact moment, what I believe is that I have stated an ordering where if you compile A, B, or C, you must build D after that, but I have not stated ANY dependency such that D must be *delayed* until A, B and C have completed.
⁇
We seem to get the behavior we want if we give D an AfterTargets="A;B;C" AND a DependsOnTargets="A;B;C". Okay. I…
I think this is correct?
I'm entirely unfamiliar with msbuild, but having a target as its own AfterTarget feels wrong, so I agree this looks more correct....
@mcc if target A has AfterTargets="B" then running B will also run A afterwards, if target A has DependsOnTargets="B" then running A will also run B first
@mcc As I understand it, they are close to the inverse of each other.
Thinking in terms of what triggers what:
"AfterTargets" will trigger the target you're defining when _they_ are built, but you can build the target you're defining without triggering them.
"DependsOnTargets" are triggered before the target _you're defining_ is built, but your target won't always be triggered if they are.