Commit b85d9b7
committed
Add multiple safeties around the RemoveDir task
So that we don't end up nuking the whole git repository!
It was my misunderstanding that targets setup with `AfterTargets` would not run if the target specified was skipped because its condition would evaluate to false. When trying to add multitargeting, the `MoveCoverletReport` target ran anyway and the `CoverletReport` item evaluated to empty which in turn made `CoverletReportParentDirectory` evaluate to `..`, i.e the root of the git repository which was then deleted by the `RemoveDir` task.
Two safeties have been added:
1. Add the same `Condition="$(TargetFramework) != ''"` on all targets running after `GenerateHtmlCoverageReport`.
1. Add `Condition="$(CoverletReport) != ''"` when defining the `CoverletReportParentDirectory` item.
This incident would never have happened in the first place if:
1. I could have used `$([System.IO.Directory]::GetParent($(CoverletReport)))` instead of `$([System.IO.Path]::Combine($(CoverletReport),'..'))` because the former would have crashed when `$(CoverletReport)` evaluates to empty, the latter just silently picked the wrong parent directory. But I did not use the former because of a [Rider bug][1].
2. VS Test would not [create test results in non deterministic paths][2]. The `MoveCoverletReport` target would not have been needed at all.
[1]: https://youtrack.jetbrains.com/issue/RIDER-92994
[2]: microsoft/vstest#23781 parent f48caec commit b85d9b7
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments