Using a dockerfile argument in a RUN statement

Well, I found a solution that works but it's definitely not ideal. It appears variables simply aren't expanded in RUN statements (at least on Windows, haven't tried Linux). However, the COPY statement will expand them. So, I can copy my file to a temp file with a hard coded name, and then use that:

COPY ./ /inetpub/wwwroot/
COPY ${transform} /inetpub/wwwroot/Web.Current.config
RUN powershell -executionpolicy bypass /Build/Transform.ps1 -xml "/inetpub/wwwroot/web.config" -xdt "/inetpub/wwwroot/Web.Current.config"

In this particular situation, it works for me.

Update: Found another method that works

This is perhaps a better method using environment variables:

FROM someimage
ARG transform
ENV TransformFile ${transform}

COPY ./ /inetpub/wwwroot/
RUN powershell -executionpolicy bypass /Build/Transform.ps1 -xml "/inetpub/wwwroot/web.config" -xdt "/inetpub/wwwroot/$ENV:TransformFile"

In this case, Docker will evaluate the parameter transform and set it to the environment variable TransformFile. When I use it in the PowerShell script, it's no longer Docker that's evaluating the argument, but Powershell itself. Thus, the Powershell syntax for interpolating an environment variable must be used.