title: How to add NuGet packages to the Dockerfile build steps?
body: <p>I have a small .NET Framework 4.6.2 application with a few NuGet package references. On executing: <code>docker build -t myapp .</code> I receive the error: <code>Could not resolve this reference.</code> for each of the referenced NuGet packages.</p>
  
  <p>I have tried:</p>
  
  <ul>
  <li>Adding <code>RUN ["dotnet", "restore"]</code> to restore the packages from the .csproj</li>
  <li>Changing the image tag to <code>:4.6.2</code></li>
  </ul>
  
  <p>How do I add the NuGet packages to the build proces?</p>
  
  <p>Thanks for your time!</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM microsoft/dotnet-framework-build:4.7.1 as build-env
  
  WORKDIR /app
  COPY . /app
  
  RUN ["dotnet", "build"]
  
  FROM microsoft/dotnet-framework:4.7.1
  WORKDIR /app
  COPY --from=build-env /app .
  
  ENTRYPOINT ["MessageProcessor.exe"]
  </code></pre>
  
  <p>Full error for a single reference from the Build step:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "GreenPipes, Version=1.2.1.98, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\app\MessageProcessor.csproj]
  </code></pre>