6
votes

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?

1
Are you confusing PCL with Application? ASP.NET Core application are also in a dll, but it's technically not a "PCL", since a) ASP.NET Core (on .NET Core) targets 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 (a Main method), PCL doesn't, so you are most likely having a wrong target. Do not target netstandardx.y, but target netcoreappx.y instead. With dotnet run you can only run applications (targeting >=net45 or netcoreappx.y)Tseng
As in my Dockerfile, my "application" is the MyWebApp.dll, which is an ASP.NET Core application, which targets netcoreapp1.1. I have a library project "MyPCL" which the web app is referencing, which is a portable class library which is targeting PCL profile111. My understanding is that currently dotnet is not able to build anything other than netcoreapp at this stage. But I feel it should be able to build portable class libraries.marcusturewicz

1 Answers