【发布时间】:2021-11-23 09:15:17
【问题描述】:
我想为 docker 创建本地 nuget 包 在 nuget.config 中,为 nuget 存储库添加“C:\Program Files (x86)\Microsoft SDKs\NuGetPackages”,在运行时,docker 在地址的第一个添加“src”并且找不到“src\C:\程序文件 (x86)\Microsoft SDKs\NuGetPackages"
如何在“localhost:8000”上创建本地nuget包?
我的 Dockerfile 是:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY "solution-name.sln" "PadCMS.sln"
COPY "BuildingBlocks/Core/Core.Common/Core.Common.csproj" "BuildingBlocks/Core/Core.Common/Core.Common.csproj"
COPY "BuildingBlocks/Core/Core.WebApi/Core.WebApi.csproj" "BuildingBlocks/Core/Core.WebApi/Core.WebApi.csproj"
COPY "BuildingBlocks/Core/Core/Core.csproj" "BuildingBlocks/Core/Core/Core.csproj"
COPY "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj" "BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj"
COPY "BuildingBlocks/EventBus/EventBus/EventBus.csproj" "BuildingBlocks/EventBus/EventBus/EventBus.csproj"
COPY "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj" "BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj"
COPY "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj" "BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj"
COPY "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj" "BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj"
COPY "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj" "BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHos
COPY "NuGet.config" "NuGet.config"
RUN dotnet restore "PadCMS.sln"
COPY . .
WORKDIR /src/Services/Accounting/Accounting.API
RUN dotnet publish --no-restore -c Release -o /app
FROM build AS publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Accounting.API.dll"]
【问题讨论】:
-
您的 docker 容器无法访问您的正常文件系统,因此它无法访问
C:\..(即使路径正确)。您要做的是将您COPY的某个目录中的 nuget 包包含到容器中。如果您将容器内该目录的路径添加到您的NuGet.Config中,那么dotnet应该能够使用该包源。
标签: docker .net-core docker-compose nuget