Docker Community Forums

Share and learn in the Docker community.

Asp core spa application docker build error Syntax error: “)” unexpected (expecting “then”)

I have a multi-layer application

abs.Data

abs.Common

abs.Repo

abs.Services

abs.Presentation (web API main project with angular spa project (and I just added the build of angular projects its source is separated I mean it’s not included in asp core application))

and I add a DockerFile to project with Linux container

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 ["abs.Presentation/abs.Presentation.csproj", "abs.Presentation/"]
COPY ["abs.Services/abs.Services.csproj", "abs.Services/"]
COPY ["abs.Repo/abs.Repo.csproj", "abs.Repo/"]
COPY ["abs.Common/abs.Common.csproj", "abs.Common/"]
COPY ["abs.Data/abs.Data.csproj", "abs.Data/"]
RUN dotnet restore "abs.Presentation/abs.Presentation.csproj"
COPY . .
WORKDIR "/src/abs.Presentation"
RUN dotnet build "abs.Presentation.csproj" -c Release -o /app/build

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

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

and after building it I get this error
I test a simple asp core project and its build and run fine with docker

but my main project I don’t know what is going on

5>  Restore completed in 99.55 ms for /src/abs.Repo/abs.Repo.csproj.
5>/src/abs.Presentation/abs.Presentation.csproj : warning NU1701: Package 'SkiaSharp.Views     1.68.1.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2,     .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2,     .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This     package may not be fully compatible with your project.
5>  Restore completed in 113.05 ms for /src/abs.Presentation/abs.Presentation.csproj.
5>  Restore completed in 1.76 ms for /src/abs.Data/abs.Data.csproj.
5>  Restore completed in 2.25 ms for /src/abs.Services/abs.Services.csproj.
5>  Restore completed in 3.7 ms for /src/abs.Common/abs.Common.csproj.
5>  /bin/sh: 2: /tmp/tmp51502467b4fe4a7dabdaa04f2849f103.exec.cmd: Syntax error: ")" unexpected     (expecting "then")
5>/src/abs.Presentation/abs.Presentation.csproj(69,5): error MSB3073: The command "(if exist     "/app/build/*old.exe" del "/app/build/*old.exe") & (if exist "/app/build/*.exe" ren "/app/build/*.exe"     *.old.exe)" exited with code 2.
5>Build FAILED.
5>
5>/src/abs.Presentation/abs.Presentation.csproj : warning NU1701: Package 'SkiaSharp.Views     1.68.1.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2,     .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2,     .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This     package may not be fully compatible with your project.
5>/src/abs.Presentation/abs.Presentation.csproj(69,5): error MSB3073: The command "(if exist     "/app/build/*old.exe" del "/app/build/*old.exe") & (if exist "/app/build/*.exe" ren "/app/build/*.exe"     *.old.exe)" exited with code 2.
5>    1 Warning(s)
5>    1 Error(s)
5>
5>Time Elapsed 00:00:04.67
5>Removing intermediate container b1502d9e6b5a
5>The command '/bin/sh -c dotnet build "abs.Presentation.csproj" -c Release -o /app/build'     returned a non-zero code: 1
5>d:\tuts\daneshjooyar\projectfile\abs-server\abs.presentation\dockerfile : error CTC1014: Docker     command failed with exit code 1.
5>d:\tuts\daneshjooyar\projectfile\abs-server\abs.presentation\dockerfile : error CTC1014: The     command '/bin/sh -c dotnet build "abs.Presentation.csproj" -c Release -o /app/build' returned a non-    zero code: 1
5>Done building project "abs.Presentation.csproj" -- FAILED.
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========