当我尝试 docker build 时,我的每个 csharp 项目都无法计算缓存(又名无法找到)

问题描述 投票:0回答:1

我已经为这个问题苦恼了好几个星期了,我似乎找不到 docker 突然找不到我的项目的原因。对于上下文,我使用 Visual Studio 上的自动 dockerfile gen,该工具已运行多年。但突然一个月前。它只是无法找到任何项目。

dockerfile

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["RESTAPI/RESTAPI.csproj", "RESTAPI/"]
COPY ["Domain/Domain.csproj", "Domain/"]
COPY ["JsonService/JsonService.csproj", "JsonService/"]
COPY ["JsonRepository/JsonRepository.csproj", "JsonRepository/"]
RUN dotnet restore "./RESTAPI/RESTAPI.csproj"
COPY . .
WORKDIR "/src/RESTAPI"
RUN dotnet build "./RESTAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./RESTAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

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

docker 错误

2024/05/05 18:17:53 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
[+] Building 0.0s (0/0)  docker:default
2024/05/05 18:17:53 http2: server: error reading preface from client //./pipe/docker_engine: file has already been close[+] Building 0.2s (12/20)                                                                                docker:default
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 1.04kB                                                                             0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0                                                  0.2s
 => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0                                               0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [build  1/10] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:03476e8b974ca8e5084bf63742d85f04a5f53df0ae37c82d31  0.0s
 => [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:8.0                                                            0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 8.65kB                                                                                0.0s
 => CACHED [build  2/10] WORKDIR /src                                                                              0.0s
 => ERROR [build  3/10] COPY [RESTAPI/RESTAPI.csproj, RESTAPI/]                                                    0.0s
 => ERROR [build  4/10] COPY [Domain/Domain.csproj, Domain/]                                                       0.0s
 => ERROR [build  5/10] COPY [JsonService/JsonService.csproj, JsonService/]                                        0.0s
 => ERROR [build  6/10] COPY [JsonRepository/JsonRepository.csproj, JsonRepository/]                               0.0s
------
 > [build  3/10] COPY [RESTAPI/RESTAPI.csproj, RESTAPI/]:
------
------
 > [build  4/10] COPY [Domain/Domain.csproj, Domain/]:
------
------
 > [build  5/10] COPY [JsonService/JsonService.csproj, JsonService/]:
------
------
 > [build  6/10] COPY [JsonRepository/JsonRepository.csproj, JsonRepository/]:
------
Dockerfile:15
--------------------
  13 |     COPY ["Domain/Domain.csproj", "Domain/"]
  14 |     COPY ["JsonService/JsonService.csproj", "JsonService/"]
  15 | >>> COPY ["JsonRepository/JsonRepository.csproj", "JsonRepository/"]
  16 |     RUN dotnet restore "./RESTAPI/RESTAPI.csproj"
  17 |     COPY . .
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 7d361eef-1f98-4f82-921b-eb8642d4e9e0::7zd4dryeosmuxw0c8pztwiwua: "/JsonRepository/JsonRepository.csproj": not found

最后是我的文件树

G:.
│   .dockerignore
│   .gitignore
│   JSONRequestHub.sln
│
├───Domain
│   │   Domain.csproj
│   │
│   ├───BasicJson
│   │       JsonAddress.cs
│   │       JsonArticle.cs
│   │       JsonComment.cs
│   │       JsonEvent.cs
│   │       JsonFinancialTransaction.cs
│   │       JsonOrder.cs
│   │       JsonProduct.cs
│   │       JsonRandom.cs
│   │       JsonUser.cs
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.deps.json
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   ├───Enums
│   │       ObjectTypes.cs
│   │
│   ├───obj
│   │   │   Domain.csproj.nuget.dgspec.json
│   │   │   Domain.csproj.nuget.g.props
│   │   │   Domain.csproj.nuget.g.targets
│   │   │   project.assets.json
│   │   │   project.nuget.cache
│   │   │
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│   │   │       │   Domain.AssemblyInfo.cs
│   │   │       │   Domain.AssemblyInfoInputs.cache
│   │   │       │   Domain.assets.cache
│   │   │       │   Domain.csproj.AssemblyReference.cache
│   │   │       │   Domain.csproj.BuildWithSkipAnalyzers
│   │   │       │   Domain.csproj.CoreCompileInputs.cache
│   │   │       │   Domain.csproj.FileListAbsolute.txt
│   │   │       │   Domain.dll
│   │   │       │   Domain.GeneratedMSBuildEditorConfig.editorconfig
│   │   │       │   Domain.GlobalUsings.g.cs
│   │   │       │   Domain.pdb
│   │   │       │   Domain.sourcelink.json
│   │   │       │
│   │   │       ├───ref
│   │   │       │       Domain.dll
│   │   │       │
│   │   │       └───refint
│   │   │               Domain.dll
│   │   │
│   │   └───Release
│   │       └───net8.0
│   │           │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│   │           │   Domain.AssemblyInfo.cs
│   │           │   Domain.AssemblyInfoInputs.cache
│   │           │   Domain.assets.cache
│   │           │   Domain.csproj.AssemblyReference.cache
│   │           │   Domain.GeneratedMSBuildEditorConfig.editorconfig
│   │           │   Domain.GlobalUsings.g.cs
│   │           │
│   │           ├───ref
│   │           └───refint
│   └───Shared
│           Settings.cs
│
├───JsonRepository
│   │   BasicJsonRepository.cs
│   │   IBasicJsonRepository.cs
│   │   JsonGenerate.cs
│   │   JsonGetData.cs
│   │   JsonRepository.csproj
│   │   MongoDbContext.cs
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │           JsonRepository.deps.json
│   │   │           JsonRepository.dll
│   │   │           JsonRepository.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   └───obj
│       │   JsonRepository.csproj.nuget.dgspec.json
│       │   JsonRepository.csproj.nuget.g.props
│       │   JsonRepository.csproj.nuget.g.targets
│       │   project.assets.json
│       │   project.nuget.cache
│       │
│       ├───Debug
│       │   └───net8.0
│       │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│       │       │   JsonRepo.65D78EE7.Up2Date
│       │       │   JsonRepository.AssemblyInfo.cs
│       │       │   JsonRepository.AssemblyInfoInputs.cache
│       │       │   JsonRepository.assets.cache
│       │       │   JsonRepository.csproj.AssemblyReference.cache
│       │       │   JsonRepository.csproj.BuildWithSkipAnalyzers
│       │       │   JsonRepository.csproj.CoreCompileInputs.cache
│       │       │   JsonRepository.csproj.FileListAbsolute.txt
│       │       │   JsonRepository.dll
│       │       │   JsonRepository.GeneratedMSBuildEditorConfig.editorconfig
│       │       │   JsonRepository.GlobalUsings.g.cs
│       │       │   JsonRepository.pdb
│       │       │   JsonRepository.sourcelink.json
│       │       │
│       │       ├───ref
│       │       │       JsonRepository.dll
│       │       │
│       │       └───refint
│       │               JsonRepository.dll
│       │
│       └───Release
│           └───net8.0
│               │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│               │   JsonRepository.AssemblyInfo.cs
│               │   JsonRepository.AssemblyInfoInputs.cache
│               │   JsonRepository.assets.cache
│               │   JsonRepository.csproj.AssemblyReference.cache
│               │   JsonRepository.GeneratedMSBuildEditorConfig.editorconfig
│               │   JsonRepository.GlobalUsings.g.cs
│               │
│               ├───ref
│               └───refint
├───JsonService
│   │   BasicJsonService.cs
│   │   IBasicJsonService.cs
│   │   JsonService.csproj
│   │
│   ├───bin
│   │   ├───Debug
│   │   │   └───net8.0
│   │   │           Domain.dll
│   │   │           Domain.pdb
│   │   │           JsonRepository.dll
│   │   │           JsonRepository.pdb
│   │   │           JsonService.deps.json
│   │   │           JsonService.dll
│   │   │           JsonService.pdb
│   │   │
│   │   └───Release
│   │       └───net8.0
│   └───obj
│       │   JsonService.csproj.nuget.dgspec.json
│       │   JsonService.csproj.nuget.g.props
│       │   JsonService.csproj.nuget.g.targets
│       │   project.assets.json
│       │   project.nuget.cache
│       │
│       ├───Debug
│       │   └───net8.0
│       │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│       │       │   JsonServ.FF3E0D47.Up2Date
│       │       │   JsonService.AssemblyInfo.cs
│       │       │   JsonService.AssemblyInfoInputs.cache
│       │       │   JsonService.assets.cache
│       │       │   JsonService.csproj.AssemblyReference.cache
│       │       │   JsonService.csproj.BuildWithSkipAnalyzers
│       │       │   JsonService.csproj.CoreCompileInputs.cache
│       │       │   JsonService.csproj.FileListAbsolute.txt
│       │       │   JsonService.dll
│       │       │   JsonService.GeneratedMSBuildEditorConfig.editorconfig
│       │       │   JsonService.GlobalUsings.g.cs
│       │       │   JsonService.pdb
│       │       │   JsonService.sourcelink.json
│       │       │
│       │       ├───ref
│       │       │       JsonService.dll
│       │       │
│       │       └───refint
│       │               JsonService.dll
│       │
│       └───Release
│           └───net8.0
│               │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
│               │   JsonService.AssemblyInfo.cs
│               │   JsonService.AssemblyInfoInputs.cache
│               │   JsonService.assets.cache
│               │   JsonService.csproj.AssemblyReference.cache
│               │   JsonService.GeneratedMSBuildEditorConfig.editorconfig
│               │   JsonService.GlobalUsings.g.cs
│               │
│               ├───ref
│               └───refint
└───RESTAPI
    │   appsettings.Development.json
    │   appsettings.json
    │   Dockerfile
    │   Dockerfile.original
    │   Dockerfile1.original
    │   Program.cs
    │   RESTAPI.csproj
    │   RESTAPI.csproj.user
    │
    ├───bin
    │   ├───Debug
    │   │   └───net8.0
    │   │       │   appsettings.Development.json
    │   │       │   appsettings.json
    │   │       │   AWSSDK.Core.dll
    │   │       │   AWSSDK.SecurityToken.dll
    │   │       │   DnsClient.dll
    │   │       │   Domain.dll
    │   │       │   Domain.pdb
    │   │       │   JsonRepository.dll
    │   │       │   JsonRepository.pdb
    │   │       │   JsonService.dll
    │   │       │   JsonService.pdb
    │   │       │   Microsoft.Extensions.DependencyModel.dll
    │   │       │   Microsoft.Extensions.Options.dll
    │   │       │   Microsoft.OpenApi.dll
    │   │       │   MongoDB.Bson.dll
    │   │       │   MongoDB.Driver.Core.dll
    │   │       │   MongoDB.Driver.dll
    │   │       │   MongoDB.Libmongocrypt.dll
    │   │       │   RESTAPI.deps.json
    │   │       │   RESTAPI.dll
    │   │       │   RESTAPI.exe
    │   │       │   RESTAPI.pdb
    │   │       │   RESTAPI.runtimeconfig.json
    │   │       │   RESTAPI.xml
    │   │       │   Serilog.AspNetCore.dll
    │   │       │   Serilog.dll
    │   │       │   Serilog.Enrichers.Environment.dll
    │   │       │   Serilog.Extensions.Hosting.dll
    │   │       │   Serilog.Extensions.Logging.dll
    │   │       │   Serilog.Formatting.Compact.dll
    │   │       │   Serilog.Settings.Configuration.dll
    │   │       │   Serilog.Sinks.Console.dll
    │   │       │   Serilog.Sinks.Debug.dll
    │   │       │   Serilog.Sinks.File.dll
    │   │       │   Serilog.Sinks.PeriodicBatching.dll
    │   │       │   Serilog.Sinks.Seq.dll
    │   │       │   SharpCompress.dll
    │   │       │   Snappier.dll
    │   │       │   Swashbuckle.AspNetCore.Swagger.dll
    │   │       │   Swashbuckle.AspNetCore.SwaggerGen.dll
    │   │       │   Swashbuckle.AspNetCore.SwaggerUI.dll
    │   │       │   ZstdSharp.dll
    │   │       │
    │   │       └───runtimes
    │   │           ├───linux
    │   │           │   └───native
    │   │           │           libmongocrypt.so
    │   │           │
    │   │           ├───osx
    │   │           │   └───native
    │   │           │           libmongocrypt.dylib
    │   │           │
    │   │           └───win
    │   │               └───native
    │   │                       mongocrypt.dll
    │   │
    │   └───Release
    │       └───net8.0
    ├───Controllers
    │       BasicJsonController.cs
    │
    ├───Middleware
    │       IpRateLimitMiddleware.cs
    │
    ├───obj
    │   │   project.assets.json
    │   │   project.nuget.cache
    │   │   RESTAPI.csproj.nuget.dgspec.json
    │   │   RESTAPI.csproj.nuget.g.props
    │   │   RESTAPI.csproj.nuget.g.targets
    │   │
    │   ├───Debug
    │   │   └───net8.0
    │   │       │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
    │   │       │   apphost.exe
    │   │       │   RESTAPI.AssemblyInfo.cs
    │   │       │   RESTAPI.AssemblyInfoInputs.cache
    │   │       │   RESTAPI.assets.cache
    │   │       │   RESTAPI.csproj.AssemblyReference.cache
    │   │       │   RESTAPI.csproj.BuildWithSkipAnalyzers
    │   │       │   RESTAPI.csproj.CoreCompileInputs.cache
    │   │       │   RESTAPI.csproj.FileListAbsolute.txt
    │   │       │   RESTAPI.csproj.Up2Date
    │   │       │   RESTAPI.dll
    │   │       │   RESTAPI.GeneratedMSBuildEditorConfig.editorconfig
    │   │       │   RESTAPI.genruntimeconfig.cache
    │   │       │   RESTAPI.GlobalUsings.g.cs
    │   │       │   RESTAPI.MvcApplicationPartsAssemblyInfo.cache
    │   │       │   RESTAPI.MvcApplicationPartsAssemblyInfo.cs
    │   │       │   RESTAPI.pdb
    │   │       │   RESTAPI.sourcelink.json
    │   │       │   RESTAPI.xml
    │   │       │   staticwebassets.build.json
    │   │       │
    │   │       ├───ref
    │   │       │       RESTAPI.dll
    │   │       │
    │   │       ├───refint
    │   │       │       RESTAPI.dll
    │   │       │
    │   │       └───staticwebassets
    │   │               msbuild.build.RESTAPI.props
    │   │               msbuild.buildMultiTargeting.RESTAPI.props
    │   │               msbuild.buildTransitive.RESTAPI.props
    │   │
    │   └───Release
    │       └───net8.0
    │           │   .NETCoreApp,Version=v8.0.AssemblyAttributes.cs
    │           │   RESTAPI.AssemblyInfo.cs
    │           │   RESTAPI.AssemblyInfoInputs.cache
    │           │   RESTAPI.assets.cache
    │           │   RESTAPI.csproj.AssemblyReference.cache
    │           │   RESTAPI.GeneratedMSBuildEditorConfig.editorconfig
    │           │   RESTAPI.GlobalUsings.g.cs
    │           │
    │           ├───ref
    │           └───refint
    └───Properties
            launchSettings.json

如果你能帮助我。提前致谢,此时我失去了希望,这可能是我错过的简单错误或其他原因。

尝试移入新驱动器仍然失败

也重新安装了 docker,看看是否修复了它,但没有。

询问人工智能更多次,然后我记得他们是否知道答案,否则它无法找到你的文件。

安装的 linux 移植文件超出了运行命令的范围,但仍然失败..

c# .net docker compiler-errors dockerfile
1个回答
0
投票

我找到了一个解决方案,显然 docker compose 工作正常?????? 我不知道为什么会这样

© www.soinside.com 2019 - 2024. All rights reserved.