1

I have a .NET Core project that contained 2 projects:

SLN: 
     - Web-API
     - Infrastructure

I was building it with docker using this dockerfile

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
COPY . ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/ .
ENTRYPOINT ["dotnet", "/app/Lab/out/API.dll"]

But now I have created a Web application as well in my solution

SLN:
 - Web-API
 - Web-App
 - Infrastructure

Suddenly, docker isn't building anymore. How come? How can I create two docker containers based on the same solution one for the Web-API and one for the Web-app?

Error message from Docker:

The "GetDotNetHost" task could not be loaded from the assembly /usr/share/dotnet/sdk/NuGetFallbackFolder/microsoft.aspnetcore.mvc.razor.viewcompilation/2.0.3/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks.dll. Assembly with same name is already loaded Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/app/Lab/API.csproj]

12
  • how do you build? seems this isn't docker error Commented May 4, 2018 at 9:36
  • I build using Docker Build with the Dockerfile displayed above.. if I remove the Web-API project or remove the Web-App project the build works, but when I have both of them in the solution, the build fails. Commented May 4, 2018 at 9:53
  • If you're using docker-compose file in VS 2017, open a command line on the solution directory and try docker-compose down. Also try cleaning the solution and rebuilding. From your description, to me it looks like you're using the VS2017 built in docker support, it can be flaky. Especially if docker asks questions, VS wont allow you to answer them. Commented May 4, 2018 at 11:09
  • sorry, again, this is something coming from your IDE, the error message isn't from docker Commented May 4, 2018 at 12:21
  • 1
    I'm guessing, this is from the run command RUN dotnet publish -c Release -o out, just for sake of finding the issue, you can comment this line and try again Commented May 4, 2018 at 14:11

1 Answer 1

1

So this problem is now finally fixed. It actually turned out it was a problem while compiling a .net core 2.0 project when having Razor views available:

Razor view precompilation is currently unavailable when performing a self-contained deployment (SCD) in ASP.NET Core 2.0. The feature will be available for SCDs when 2.1 releases. For more information, see View compilation fails when cross-compiling for Linux on Windows.

What I needed to do was to add the nuget package:

Microsoft.AspNetCore.Mvc.Razor.ViewCompilation

in my project to make it work. Strange thing was that it was building inside visual studio for Mac but not from the command prompt.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.