У меня есть следующая структура проекта (решения)
Inside src:
- ProjectMe.Api
- ProjectMe.Common
- Услуги
Внутренние услуги:
Dockerfile проекта ProjectMe.Api:
FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 80/tcp
ENTRYPOINT ["dotnet", "ProjectMe.Api.dll"]
И у меня есть файл docker-compose:
version: '3'
services:
rabbitmq:
image: "rabbitmq:3-management"
hostname: "rabbitmq-localhost"
container_name: rabbitmq
ports:
- "15672:15672"
- "5672:5672"
projectme.api:
image: projectme/projectme.api
build:
context: ./src/ProjectMe.Api
dockerfile: Dockerfile
ports:
- "8080:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development
# volumes:
# - ./Projectme.api/bin/pub/:/app
container_name: projectme.api
depends_on:
- service.lot
service.lot:
image: projectme/services.lot
environment:
- ConnectionString=Server=sql.data;User=sa;Password=Pass@word;Database=projectme.loans;
- ASPNETCORE_ENVIRONMENT=Development
build:
context: ./src/Services/Services.Lot
dockerfile: Dockerfile
ports:
- "8081:80"
# volumes:
# - ./Services.Lot/bin/pub/:/app
container_name: service.lot
depends_on:
- sql.data
- rabbitmq
sql.data:
# image: mssql-linux
build:
context: ./src/ProjectMe.Common/Database
dockerfile: Dockerfile
ports:
- "5433:1433"
container_name: mssql-linux
user.data:
image: redis
Iзапустите docker-compose up -d
и получите на этом шаге ошибку:
Building projectme.api
Step 1/11 : FROM microsoft/dotnet:2.0-sdk AS build-env
---> 9e06837225a4
Step 2/11 : WORKDIR /app
---> Using cache
---> 9ffccd44cc91
Step 3/11 : COPY *.csproj ./
---> Using cache
---> 34b24faea5b3
Step 4/11 : RUN dotnet restore
---> Using cache
---> ecfcdb36ee89
Step 5/11 : COPY . ./
---> Using cache
---> 4113de886250
Step 6/11 : RUN dotnet publish -c Release -o out
/usr/share/dotnet/sdk/2.1.202/NuGet.targets(928,5): warning MSB3202: The project file "/ProjectMe.Common/ProjectMe.Common.csproj" was not found. [/app/SupplyMe.Api.csproj]
/usr/share/dotnet/sdk/2.1.202/NuGet.targets(1019,5): warning MSB3202: The project file "/ProjectMe.Common/ProjectMe.Common.csproj" was not found. [/app/SupplyMe.Api.csproj]
...............................................................
...............................................................
Controllers/LotsController.cs(6,16): error CS0234: The type or namespace name 'Common' does not exist in the namespace 'ProjectMe' (are you missing an assembly reference?) [/app/ProjectMe.Api.csproj]
...............................................................
Service 'projectme.api' failed to build: The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1
Project ProjectMe имеет ссылку на Services.Common.Когда я запускаю локальную команду без докера dotnet publish -c Release -o out Проект публикует в папку без ошибок.
Не могли бы вы помочь мне понять, почему я не могу найти другой мой проект ProjectMe.Common?Как решить этот тип ошибки?