title: Using gitlab-ci to build .NET Core projects in docker
body: <p>I want to automate my deployment process using gitlab-ci. I'm doing so manually via ssh at the moment. The steps are:</p>
  
  <p>Build:</p>
  
  <ul>
  <li>dotnet restore</li>
  <li>dotnet publish</li>
  </ul>
  
  <p>This leaves me with a directory full of .dlls. I want to deploy these to a docker container, so I run:</p>
  
  <ul>
  <li>docker build</li>
  <li>docker stop</li>
  <li>docker rm</li>
  <li>docker run</li>
  </ul>
  
  <p>However, I'm having a hard time finding the proper way to do both in the same <code>.gitlab.ci.yml</code> file.</p>
  
  <p>I need the dotnet tooling from <code>microsoft/dotnet:latest</code> and the docker cli tools from <code>docker:latest</code>.</p>
  
  <p>I tried having two stages based on each of these images, but the output is not shared. To solve this, I tried using <code>artifact</code>, but that fails to upload.</p>
  
  <p>I can't find any examples of this online, so I wonder if I'm doing something that shouldn't be done.</p>