kaise white
kaise white

Reputation: 87

Docker build image fails - No such file or directory

I created a .Net Core app in Visual Sutdio 2019 and added docker support so it automatically generates the file but when I build the docker image the output says:

1>/root/.nuget/packages/microsoft.typescript.msbuild/3.9.5/tools/Microsoft.TypeScript.targets(551,5): 
error MSB6003: The specified task executable "node" could not be run. System.ComponentModel.Win32Exception 
(2): No such file or directory [/src/CyberEvalNextGen.csproj]

I assume there is an issue with COPY but I am not sure.

Here is my docker file:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["CyberEvalNextGen.csproj", ""]
RUN dotnet restore "./CyberEvalNextGen.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "CyberEvalNextGen.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "CyberEvalNextGen.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CyberEvalNextGen.dll"]

Upvotes: 2

Views: 1084

Answers (1)

Chris Larabell
Chris Larabell

Reputation: 168

I had the same issue. The error is a bit misleading because it has your .csproj listed at the end, but this is the key part:

The specified task executable "node" could not be run.

It is actually looking to run the command "node" and it cannot find the executable. To resolve this, I added Node.js just prior to my build step.

...
WORKDIR "/src/."
#Installing Node.js in build container
RUN apt-get update && apt-get -y install nodejs                   
RUN dotnet build "CyberEvalNextGen.csproj" -c Release -o /app/build
...

This is using Linux containers, but I believe you can do something similar with PowerShell in Windows containers.

Upvotes: 5

Related Questions