Merge branch 'backport-fix-custom-target-with-csharp' into release-3.12

Merge-request: !2549