Home > front end >  Docker skip project on build
Docker skip project on build

Time:07-18

I have dockerfile with this config

FROM mcr.microsoft.com/dotnet/sdk:6.0 as builder

WORKDIR /app
COPY . .

RUN apt-get update;apt-get install curl; apt-get -y install zip

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

RUN unzip awscliv2.zip

RUN ./aws/install

ENV PATH="${PATH}:/root/.dotnet/tools"

#RUN dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider
#
#RUN dotnet codeartifact-creds install
#
#RUN aws codeartifact login --tool dotnet --domain monspire --domain-owner 986853728599  --repository monspire

RUN dotnet restore

RUN dotnet publish -c Release TooSee.Web.Host.csproj

# create the runnable container...
FROM mcr.microsoft.com/dotnet/sdk:6.0

# install dependencies
RUN apt-get update \
    && apt-get install -y --allow-unauthenticated \
        libc6-dev \
        libgdiplus \
        libx11-dev \
     && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=builder /app/src/TooSee.Web.Host/bin/Debug/net6.0/publish/ .

ARG ENVIRONMENT
ENV ENVIRONMENT=${ENVIRONMENT}

EXPOSE 80
CMD ["dotnet", "TooSee.Web.Host.dll"]

And try to run it via docker build -t tooseeapi .

But for reasons it skipped .Core project

Here is log

=> ERROR [builder 9/9] RUN dotnet publish -c Release TooSee.Web.Host.csproj 6.9s


[builder 9/9] RUN dotnet publish -c Release TooSee.Web.Host.csproj: #15 0.750 Microsoft (R) Build Engine version 17.2.0 41abc5629 for .NET #15 0.750 Copyright (C) Microsoft Corporation. All rights reserved. #15 0.750 #15 2.054 Determining projects to restore... #15 2.057 Skipping project "/TooSee.Web.Core/TooSee.Web.Core.csproj" because it was not found. #15 2.060 Skipping project "/TooSee.Web.Core/TooSee.Web.Core.csproj" because it was not found. #15 2.385 All projects are up-to-date for restore. #15 3.150 /usr/share/dotnet/sdk/6.0.302/Microsoft.Common.CurrentVersion.targets(2066,5): warning : The referenced project '../TooSee.Web.Core/TooSee.Web.Core.csproj' does not exist. [/app/TooSee.Web.Host.csproj]

Dockerfile is under this path - C:\Users\nemes\Documents\GitHub\tooseeapi\src\TooSee.Web.Host

And .Core is here

C:\Users\nemes\Documents\GitHub\tooseeapi\src\TooSee.Web.Core

But if I run dotnet publish -c Release TooSee.Web.Host.csproj I got no errors

Why it's skipped and how I can fix this?

CodePudding user response:

you have to keep your docker file at this location

C:\Users\nemes\Documents\GitHub\tooseeapi\src

and copy both project files separately. something like

COPY ["TooSee.Web.Host/TooSee.Web.Host.csproj", "./"]
COPY ["TooSee.Web.Core/TooSee.Web.Core.csproj", "./"]
  • Related