There is a new feature in the Team Foundation Server 2017 (on prem.). You can use variables in the repository mappings. There is however a bug related to the “Get Sources” step.
If there is at least one not dynamically mapped repository, then the latest version gets calculated based on that. It usually results in not having the latest version for the dynamically mapped repository paths. The following trick solves this problem:
Just add an $(emtpy.path) variable usage into the “static” mappings to ensure the latest version for the build.
I see it in fact as a bug in TFS.