I am trying to build an ASP.NET Core docker image with following Dockerfile:
FROM microsoft/aspnetcore-build:1.1.1
WORKDIR /app
COPY src .
RUN dotnet restore
RUN dotnet publish --output /out/ --configuration Release
EXPOSE 5000
ENTRYPOINT ["dotnet","/out/MyWebApp.dll"]
The build fails, and it gives the following error:
/app/MyPCL/MyPCL.csproj(70,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/1.0.1/Microsoft/Portable/v4.5/Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
So it is having trouble building the PCL library, as it can't find Microsoft.Portable.CSharp.targets.
My PCL project file has the following import statement:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
which I am thinking is causing the problem, as this path must not exist in the docker container. BTW, the project builds and runs perfectly in Visual Studio 2017.
Any ideas?
netcoreapp1.1
which means it can only run there and not on i.e. .NET Framework or Windows Mobile, so it runs only on a single platform and b) the "application dll" has an entry point (aMain
method), PCL doesn't, so you are most likely having a wrong target. Do not targetnetstandardx.y
, but targetnetcoreappx.y
instead. Withdotnet run
you can only run applications (targeting >=net45
ornetcoreappx.y
) – Bursar