unable to get target location

Notice that even the documentation you quoted says “It was meant to get the location of an
executable target’s output file” (emphasis mine). You have a custom target, not an executable target. Custom targets don’t have outputs, so they don’t have a location, and have never had one.

If your custom target produces something at a path on disk, you should use your knowledge of that path directly instead of trying to query it from the target. If that proves difficult due to scoping or knowledge-separation issues, you can set a custom property on the custom target which will store that path, and retrieve that property at the point you need to use it.