I need to copy a specific git hook file into the local repo on MSBuild to enforce some client side validation which work fine in general, however, I noticed there are exceptional cases where worktrees are setup slightly different from the suggested config. This can be get around if the DestPath
below is acquire when the task is being execute from git rev-parse --git-path hooks
.
<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="@(HookFiles)"
DestinationFolder="$(DestPath)"
OverwriteReadOnlyFiles="True"
/>
My guess is to add an Exec task in front of Copy to collect the variable but I am not sure how to make the output available in the Copy task.
<Exec Command="git rev-parse --git-path hooks"/>