
[英]The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
[英]Dockerfile crashing with the type or namespace 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore'
我创建了一个API服务,其中包含三个不同的项目。 为了部署它,我创建了一个docker容器来包含所有内容。 我的Dockerfile包含以下内容。
#Select an OS Image
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
#Set a working directory
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.sln .
COPY ProductOrders.Service/*.csproj ./ProductOrders.Service/
COPY ProductOrders.Repository/*.csproj ./ProductOrders.Repository/
COPY ProductOrders.Models/*.csproj ./ProductOrders.Models/
COPY ProductOrders.Service.Tests/*.csproj ./ProductOrders.Service.Tests/
COPY ProductOrders.Repository.Tests/*.csproj ./ProductOrders.Repository.Tests/
RUN dotnet restore
# Copy everything else and build
COPY ProductOrders.Service/. ./ProductOrders.Service/
WORKDIR /app/ProductOrders.Service
RUN dotnet publish -c Release -o out
COPY ProductOrders.Repository/. ./ProductOrders.Repository/
WORKDIR /app/ProductOrders.Repository
RUN dotnet publish -c Release -o out
COPY ProductOrders.Models/. ./ProductOrders.Models/
WORKDIR /app/ProductOrders.Models
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
WORKDIR /app
COPY --from=build-env /app/TeamA/out ./
ENTRYPOINT ["dotnet", "ProductOrders.Service.dll"]
当它到达上一个RUN dotnet publish -c Release -i out
我崩溃了,它无法加载使用对Microsoft.AspNetCore.Mvc
引用的任何内容
出现的第一个错误状态
The type or namespace 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
这是我第一次使用Docker,在此之前一切都很好,如果能在需要时提供任何代码示例,我们将不胜感激并乐于提供任何代码示例。
PS我知道Dockerfile可以做得更漂亮,一旦运行起来就很开心,这就是列表中的下一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.