title: Error passing build arguments to dockerfile when building an image - '$MyVersion' is not a valid version string
body: <p>I have a asp.net .net core 2.1 project and we're using docker container hosted in Linux. This has been working well. Now, we have a requirement to set the assembly version of the project when building the docker image using docker file. </p>
  
  <p>So, supposedly I can pass it as build-arg when building the docker image with dockerfile. But, I can't get it working.  </p>
  
  <pre><code>ARG MyVersion="0.0.1.0"
  
  FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1709 AS base
  WORKDIR /app
  EXPOSE 8081 
  
  FROM microsoft/dotnet:2.1-sdk-nanoserver-1709 AS build
  WORKDIR /src
  COPY source/MyApp/MyApp.csproj source/MyApp/  
  RUN dotnet restore source/MyApp/MyApp.csproj  
  COPY . .
  WORKDIR /src/source/MyApp
  RUN dotnet build MyApp.csproj /p:Version=$MyVersion -c Release -o /app
  
  FROM build AS publish
  RUN dotnet publish MyApp.csproj -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "MyApp.dll"]
  </code></pre>
  
  <p>and build it with the command</p>
  
  <pre><code>docker build --build-arg MyVersion=1.22.1.0 -t MyGoodApp -f MyApp.Dockerfile .
  </code></pre>
  
  <blockquote>
    <p>In linux,I get this message</p>
    
    <p>The "GetAssemblyVersion" task was not given a value for the required
    parameter "NuGetVersion"</p>
    
    <p>In windows </p>
    
    <p>C:\Program Files\dotnet\sdk\2.1.402\NuGet.targets(114,5):
    error : '$MyVersion' is not a valid version string.</p>
  </blockquote>
  
  <p>The error above indicates $MyVersion is not getting passed/set correct on the line   RUN dotnet publish MyApp.csproj /p:Version=$MyVersion -c Release -o /app</p>
  
  <p>But, I can't see what is wrong. </p>
  
  <p>Please advise,</p>