我有一个简单的ASP.NET Core 2.0应用程序,解决方案中包含两个项目。一个项目是类库(WorldLibrary.dll),被Web应用程序(WeatherWeb.dll)引用。
我已经尝试按照这里的步骤进行操作:
https://docs.docker.com/engine/examples/dotnetcore/
这是我的Dockerfile:
FROM microsoft/aspnetcore-build:2.0 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 .
ENTRYPOINT ["dotnet", "WeatherWeb.dll"]
但是,所引用的 .dll 存在问题。我从 "docker build" 命令中获得以下输出:
C:\Users\olavt\source\repos\Weather\WeatherWeb>docker build -t weather .
Sending build context to Docker daemon 6.398MB
Step 1/10 : FROM microsoft/aspnetcore-build:2.0 AS build-env
---> df4c9af52c86
Step 2/10 : WORKDIR /app
---> Using cache
---> ae9d1b099da7
Step 3/10 : COPY *.csproj ./
---> Using cache
---> 2d9f3fba6470
Step 4/10 : RUN dotnet restore
---> Using cache
---> 19af5fb355a3
Step 5/10 : COPY . ./
---> 1704520a3ced
Step 6/10 : RUN dotnet publish -c Release -o out
---> Running in 7bcdf847e4dc
/usr/share/dotnet/sdk/2.0.2/NuGet.targets(792,5): warning MSB3202: The project file "/WorldLibrary/WorldLibrary.csproj" was not found. [/app/WeatherWeb.csproj]
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1768,5): warning : The referenced project '../WorldLibrary/WorldLibrary.csproj' does not exist. [/app/WeatherWeb.csproj]
Controllers/Api/WeatherController.cs(6,7): error CS0246: The type or namespace name 'WorldLibrary' could not be found (are you missing a using directive or an assembly reference?) [/app/WeatherWeb.csproj]
Controllers/WeatherController.cs(6,7): error CS0246: The type or namespace name 'WorldLibrary' could not be found (are you missing a using directive or an assembly reference?) [/app/WeatherWeb.csproj]
Controllers/Api/WeatherController.cs(14,39): error CS0246: The type or namespace name 'Weather' could not be found (are you missing a using directive or an assembly reference?) [/app/WeatherWeb.csproj]
The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1
C:\Users\olavt\source\repos\Weather\WeatherWeb>
我该如何正确地复制所需的 .dll 文件?