title: Cannot Build .Net Core MVC solution suing Dockerfile: Project not found, missing targets, invalid project
body: <p>I am trying to build a .NET core MVC project in a Docker container via Jenkins. I have set up the pipeline to pull from git and build inside a Docker container, but I keep getting these errors when I try to build my solutions. </p>
  
  <p>I got the Dockerfile from <a href="https://docs.docker.com/engine/examples/dotnetcore/#create-a-dockerfile-for-an-aspnet-core-application" rel="nofollow noreferrer">https://docs.docker.com/engine/examples/dotnetcore/#create-a-dockerfile-for-an-aspnet-core-application</a> and changed it appropriately for my project. It is placed inside the project directory in the same folder as my .sln file. For some reason, it's failing. My file structure seems to be right, but the script cannot seem to find my project or the build tools inside the imported environment. </p>
  
  <p>Error text (Jenkins)</p>
  
  <pre><code>[fundprofiles-docker_jenkins-B5GJFHQUL2XVSIUP7TPI255RMTFK5MJKMLIMBSXSXMQQJSZSEG5A] Running shell script
  
  + docker build -t e9f05c806e193d6c1920e5d5c23ed34350c4f491 -f Dockerfile .
  
  Sending build context to Docker daemon  234.9MB
  
  Step 1/9 : FROM microsoft/aspnetcore-build:2.0 AS build-env
  
   ---&gt; 6105426f13e9
  
  Step 2/9 : COPY *.sln ./
  
   ---&gt; Using cache
  
   ---&gt; 978a5d201ae0
  
  Step 3/9 : RUN dotnet restore
  
   ---&gt; Using cache
  
   ---&gt; 2ac341942a6d
  
  Step 4/9 : COPY . ./
  
   ---&gt; 07c15ea85ca8
  
  Step 5/9 : RUN dotnet publish -c Release -o out
  
   ---&gt; Running in bf35842f7b24
  
  Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
  
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  
  
  /myapp/myapp.csproj(582,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/2.1.4/Microsoft/VisualStudio/v15.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the &lt;Import&gt; declaration is correct, and that the file exists on disk.
  
  /myapp/myapp.csproj : warning NU1503: Skipping restore for project '/myapp/myapp.csproj'. The project file may be invalid or missing targets required for restore. [/myapp.sln]
  
  /usr/share/dotnet/sdk/2.1.4/NuGet.targets(103,5): warning : Unable to find a project to restore! [/myapp.sln]
  
  /myapp/myapp.csproj(582,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/2.1.4/Microsoft/VisualStudio/v15.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the &lt;Import&gt; declaration is correct, and that the file exists on disk.
  
  The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1
  
  script returned exit code 1
  </code></pre>
  
  <p>Dockerfile: </p>
  
  <pre><code>FROM microsoft/aspnetcore-build:2.0 AS build-env
  WORKDIR /
  
  # Copy csproj and restore as distinct layers
  COPY *.sln ./
  RUN dotnet restore
  
  # Copy everything else and build
  COPY . ./
  RUN dotnet publish -c Release -o out
  
  # Build runtime image
  FROM microsoft/aspnetcore:2.0
  WORKDIR /
  COPY --from=build-env /out .
  ENTRYPOINT ["dotnet", "myApp.dll"]
  </code></pre>