简体   繁体   中英

“The specified framework 'Microsoft.NETCore.App', version '3.1.0' was not found” when create docker image for c# project

I have a c# solution with name Model.sln. It includes around 200 c# projects. I wanna create a docker image and run "dotnet build/public" commands in the image.

step 1: create Dockerfile for this solution.

FROM microsoft/dotnet:3.1.101-aspnetcore-runtime AS base
WORKDIR /Users/Model/bin/Debug/Cli/netcoreapp3.1
ENTRYPOINT ["dotnet", "Model.dll"]

step 2: run $ docker build.

step 3: $docker run -d -t -v /Users/model:/source model

step 4: $ docker exec -it magical_agnesi bash

step 5: #dotnet publish
then I got the following message: Did you mean to run dotnet SDK commands? Please install dotnet SDK from: https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Don't know why I cannot run dotnet sdk commands in this image. It works in my mac system.

You have to have to have sdk image as runtime image does not have sdk. Please add this image to your docker file.

FROM microsoft/dotnet:2.2-sdk as build

and Please check this one to get full dockerfile example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM