Docker构建失败,出现“找不到项目文件”错误

时间:2018-06-14 12:15:51

标签: docker visual-studio-2017 .net-core

我有几个dotnet核心控制台应用程序,我正在使用Linux容器上的docker。

我右键单击了我的server项目并点击了添加的Docker支持。

它自动生成了Dockerfile,在运行时我得到项目引用错误。

运行docker build -t myserver .命令会抛出错误

Step 7/13 : RUN dotnet restore ./dockertest.sln /usr/share/dotnet/sdk/2.1.300/NuGet.targets(239,5): error MSB3202: The project file "/src/client/client.csproj" was not found. [/dockertest.sln] /usr/share/dotnet/sdk/2.1.300/NuGet.targets(239,5): error MSB3202: The project file "/src/server/server.csproj" was not found. [/dockertest.sln]

FROM microsoft/aspnetcore-build:1.0-2.0 AS base
WORKDIR /app

FROM microsoft/dotnet:2.0-sdk AS build
WORKDIR /src
COPY src/server/server.csproj src/server/
COPY src/client/client.csproj src/client/
RUN dotnet restore src/server/server.csproj
COPY . .
WORKDIR /src/src/server
RUN dotnet build server.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish server.csproj -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "server.dll"]

更新: 保存对dockerfile的更改时,在输出窗口中注意到这一点 A non-critical error occurred while getting containers ready. Your project will continue to function normally. The error was: Unable to resolve the NuGet package dependency paths for the project C:\Code\dockertest\src\server\server.csproj.

更新2: 当我切换到Windows容器而不是Linux

时,这很好用

0 个答案:

没有答案