C# 命令'/bin/sh-c dotnet restore./DockerTestDebian.csproj';返回了一个非零代码:1
我创建了一个dockerfile来构建debian 9,它应该将我的vscode项目文件夹作为构建docker映像的工具,但在构建docker映像时,我遇到了两个模糊的错误。我所有的文件都在home/rydeb/Desktop/DockerTestDebian目录下 试图建立我的形象的结果C# 命令'/bin/sh-c dotnet restore./DockerTestDebian.csproj';返回了一个非零代码:1,c#,docker,visual-studio-code,.net-core,C#,Docker,Visual Studio Code,.net Core,我创建了一个dockerfile来构建debian 9,它应该将我的vscode项目文件夹作为构建docker映像的工具,但在构建docker映像时,我遇到了两个模糊的错误。我所有的文件都在home/rydeb/Desktop/DockerTestDebian目录下 试图建立我的形象的结果 Step 1/12 : FROM microsoft/dotnet:2.0-sdk as builder ---> 9e06837225a4 Step 2/12 : ENV DOTNET_CLI_T
Step 1/12 : FROM microsoft/dotnet:2.0-sdk as builder
---> 9e06837225a4
Step 2/12 : ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
---> Using cache
---> a7abd475d0e7
Step 3/12 : RUN mkdir -p /home/rydeb/Desktop/DockerBuildStuff
---> Using cache
---> 72a293c67243
Step 4/12 : WORKDIR /home/rydeb/Desktop/DockerTestDebian
---> Running in 197210d0dc93
Removing intermediate container 197210d0dc93
---> 8b696a6350b1
Step 5/12 : COPY . /DockerBuildStuff
---> d38caf512a12
Step 6/12 : WORKDIR /home/rydeb/Desktop/DockerBuildStuff/DockerTestDebian
---> Running in ba9d0a67d8f4
Removing intermediate container ba9d0a67d8f4
---> b35c16802b52
Step 7/12 : RUN dotnet restore ./DockerTestDebian.csproj
---> Running in 7d5dfb98591d
MSBUILD : error MSB1009: Project file does not exist.
Switch: ./DockerTestDebian.csproj
The command '/bin/sh -c dotnet restore ./DockerTestDebian.csproj' returned a non-zero code: 1
我的docker文件
FROM microsoft/dotnet:2.0-sdk as builder
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
RUN mkdir -p /home/rydeb/Desktop/DockerBuildStuff
WORKDIR /home/rydeb/Desktop/DockerTestDebian
COPY . /DockerBuildStuff
WORKDIR /home/rydeb/Desktop/DockerBuildStuff/DockerTestDebian
RUN dotnet restore ./DockerTestDebian.csproj
RUN dotnet publish -c release -o published -r linux-arm
FROM microsoft/dotnet:2.0.0-runtime-stretch-arm32v7
WORKDIR /root/
COPY --from=builder /root/src/app/DockerTestDebian/published .
CMD ["dotnet", "./DockerTestDebian.dll"]
我刚刚根据Docker文件成功运行了它: 我只是简单地注释掉了
RUN dotnet restore
这样做可以使恢复继续,并在
RUN dotnet publish
对我来说似乎工作得很好。在dockerfile上评论您的dotnet还原命令
#RUN dotnet restore
在我的情况下,将文件复制到我的项目文件夹的生成后事件会导致此错误 只要删除、构建并运行它,错误就消失了。(右键单击项目->属性->生成事件)
之后再次添加复制命令,所有操作都应正常工作。我也遇到了同样的问题。你找到解决方案了吗?我正试图为raspberry pi构建我的项目,但我忘了为我的项目保存docker文件,但我将给出提示,确保在docker文件中无论如何都不要使用dotnet还原,因为这会破坏我认为
##[错误]C:\Program Files(x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Sdk\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(490,5):错误DT1001:服务“eshopwebmvc”生成失败:命令“cmd/S/C dotnet publish-C Release-o out”返回非零代码:1
PS:我正在使用azure管道生成application@CodeRunner如果你能在本地运行它?我发现有时它是一个文件夹结构,考虑管道并在本地运行它可以帮助我看到问题