J'ai une application ASP.NET Core 2.0 simple avec 2 projets dans une solution. Un projet est une bibliothèque de classes (WorldLibrary.dll), référencée par l'application Web (WeatherWeb.dll).Comment ancrer une application ASP.NET Core 2.0?
J'ai essayé de suivre les étapes ici:
https://docs.docker.com/engine/examples/dotnetcore/
Ceci est mon 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"]
Mais, il y a un problème avec le .dll référencé. Je reçois la sortie suivante de la commande « build docker »:
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>
Comment dois-je obtenir le bien référencé .dll copié sur correctement?
Le modèle de projet * déjà * contient l'option permettant d'ajouter le support de docker. Avez-vous essayé –
Vous pouvez également ajouter le support Docker à partir du menu 'Project',' Docker Support' –