首页 > 解决方案 > How to update asp.net core version in dockerfile

问题描述

I'm building a docker container as a step in Azure DevOps pipeline and using the provided build pools. When I try to run the container, I get the error below. I understand I need to update the asp.net version as I build the container, and I'm looking for a command line that I can add to my Dockerfile to do so.

I've found a number of places to download the correct version but have not found a good way to put the download & install as a command in a docker file.

My Dockerfile is quite simple and is based on Windows 1803.

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-sac2016 AS runtime
WORKDIR /app
COPY SampleMvcApp/out ./
ENTRYPOINT ["dotnet", "Meta-Analytics.dll"]

A snippet from the error I get is below:

The specified framework 'Microsoft.AspNetCore.All', version '2.2.5' was not found.

The following versions are installed:
2.2.2 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]

标签: dockerasp.net-coreazure-devops

解决方案


似乎该项目在某个时候进行了升级,但并未遵循所有迁移选项。

Microsoft.AspNetCore.All在 2.1 版中已弃用对 的支持。您应该将其替换为Microsoft.AspNetCore.App并且您不应该指定版本。

<PackageReference Include="Microsoft.AspNetCore.App" />

有关详细信息,请参阅https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage?view=aspnetcore-2.2#migratehttps://docs.microsoft.com/en-us/aspnet/核心/迁移/20_21?view=aspnetcore-2.2


推荐阅读