docket build失败,当前的.NET SDK不支持定位.NET Core 2.1

时间:2018-06-10 20:46:12

标签: docker asp.net-core .net-core docker-compose

在Windows 10上执行此操作:

>docker-compose -f docker-compose.yml build
Building MyApprestapi
Step 1/17 : FROM microsoft/aspnetcore:2.0 AS base
 ---> 6237a4750408
Step 2/17 : WORKDIR /app
Removing intermediate container ae0057e8752c
 ---> d422fca6b533
Step 3/17 : EXPOSE 11001
 ---> Running in 70f6f9a9d052
Removing intermediate container 70f6f9a9d052
 ---> 673d1c1d8f34
Step 4/17 : FROM microsoft/aspnetcore-build:2.0 AS build
 ---> f5f1d9a332af
Step 5/17 : WORKDIR /src
Removing intermediate container 0c5e68914dfd
 ---> 035e0d5467bf
Step 6/17 : COPY MyAppPipeline.sln ./
 ---> b0ccbf6431b4
Step 7/17 : COPY MyAppRestApi/MyAppRestApi.csproj MyAppRestApi/
 ---> 3216ad77f880
Step 8/17 : RUN dotnet restore -nowarn:msb3202,nu1503
 ---> Running in f0b9fa8dbbd4
C:\Program Files\dotnet\sdk\2.1.200\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1.  Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [C:\src\MyAppRestApi\MyAppRestApi.csproj]
ERROR: Service 'MyApprestapi' failed to build: The command 'cmd /S /C dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1

如果我这样做:

>dotnet --info
  

.NET Core SDK(反映任何global.json):版本:2.1.300   提交:adab45bf0c

     

运行时环境:操作系统名称:Windows操作系统版本:10.0.17134   操作系统平台:Windows RID:win10-x64基本路径:C:\ Program   文件\ DOTNET \ SDK \ 2.1.300 \

     

主机(对支持很有用):版本:2.1.0提交:caa7b7e2ba

     

安装了.NET Core SDK:     1.0.0-preview2-003131 [C:\ Program Files \ dotnet \ sdk]     2.1.2 [C:\ Program Files \ dotnet \ sdk]     2.1.104 [C:\ Program Files \ dotnet \ sdk]     2.1.300 [C:\ Program Files \ dotnet \ sdk]

     

安装了.NET Core运行时:Microsoft.AspNetCore.All 2.1.0   [C:\ Program Files \ dotnet \ shared \ Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\ Program   Files \ dotnet \ shared \ Microsoft.AspNetCore.App] Microsoft.NETCore.App   1.0.1 [C:\ Program Files \ dotnet \ shared \ Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\ Program   Files \ dotnet \ shared \ Microsoft.NETCore.App] Microsoft.NETCore.App   2.0.6 [C:\ Program Files \ dotnet \ shared \ Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\ Program   文件\ DOTNET \共享\ Microsoft.NETCore.App]

     

安装其他.NET Core运行时或SDK:
  https://aka.ms/dotnet-download

1 个答案:

答案 0 :(得分:3)

问题是我的DockerFile是在项目创建时生成的。 我不得不使用这里列出的替换品:

https://github.com/aspnet/aspnet-docker/tree/master/2.1

microsoft/dotnet:2.1-aspnetcore-runtime
microsoft/dotnet:2.1-sdk