Breaking change in 'Substitute variables in files' in Octopus 3.x?

I believe I found a breaking change in Octopus 3.x ‘Substitute variables in files’ functionality. This was working before we upgraded to 3.x.

Our deployment transforms a file named ‘Endpoints.json.transform’ which uses the ‘each’ iterator for a collection named ‘WebApiEndpoints’ defined in a variable set (see attached screenshot). Each of the WebApiEndpoints items has a property call Url and the property includes a nested variable called #{AppServices.Url}. The ‘each’ keyword is partially working in the transform and it appears to be looping correctly, however it is not evaluating the nested #{AppServices.Url} variable (see the transformed output below). The #{AppServices.Url} is definitely defined because the values in the web.config are properly being updated with that variable. Again, this was working in 2.x but not in 3.x.

Endpoints.json.transform =>

[
#{each endpoint in WebApiEndpoints}
{
“Name”: “#{endpoint.Name}”,
“Url” : “#{endpoint.Url}”
}#{unless Octopus.Template.Each.Last},#{/unless}
#{/each}
]

Transformed Endpoints.json file (note: AppServices.Url is not replaced) =>

[

{
"Name": "Logging Services",
"Url" : "#{AppServices.Url}/logging"
},

{
"Name": "Quoting Services",
"Url" : "#{AppServices.Url}/quoting"
},

{
"Name": "Case Services",
"Url" : "#{AppServices.Url}/cases"
},

{
"Name": "Prt Services",
"Url" : "#{AppServices.Url}/prt"
},

{
"Name": "GeoInfo Services",
"Url" : "#{AppServices.Url}/geoInfo"
},

{
"Name": "Membership",
"Url" : "#{AppServices.Url}/membership"
},

{
"Name": "Notification",
"Url" : "#{AppServices.Url}/notifications"
},

{
"Name": "Agent Services",
"Url" : "#{AppServices.Url}/agent"
},

{
"Name": "WebOps Services",
"Url" : "#{AppServices.Url}/webops"
}

]

Update. I’ve found a temporary work around. In the ‘Target files’ section of the ‘Substitute variables in files’ panel I just add the the same file twice. The first pass expands the variable collection using the ‘each’ keyword. The second pass then expands #{AppServices.Url} variables that were injected from the first pass.