在 Windows 10 上进行此操作:
.NET Core SDK (反映任何全局.json): 版本: 2.1.300 提交: adab45bf0c 运行时环境: 操作系统名称: Windows 操作系统版本: 10.0.17134 操作系统平台: Windows RID: win10-x64 基本路径: C:\Program Files\dotnet\sdk\2.1.300\ 主机(有用的支持): 版本: 2.1.0 提交: caa7b7e2ba 已安装.NET Core SDKs: 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 Files\dotnet\shared\Microsoft.NETCore.App] 要安装其他.NET Core运行时或SDK,请访问以下链接: https://aka.ms/dotnet-download
>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 (反映任何全局.json): 版本: 2.1.300 提交: adab45bf0c 运行时环境: 操作系统名称: Windows 操作系统版本: 10.0.17134 操作系统平台: Windows RID: win10-x64 基本路径: C:\Program Files\dotnet\sdk\2.1.300\ 主机(有用的支持): 版本: 2.1.0 提交: caa7b7e2ba 已安装.NET Core SDKs: 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 Files\dotnet\shared\Microsoft.NETCore.App] 要安装其他.NET Core运行时或SDK,请访问以下链接: https://aka.ms/dotnet-download