Aspnetcore: Docker container not working for blazor server app after upgrade to pre7

Created on 28 Jul 2019  路  5Comments  路  Source: dotnet/aspnetcore

Docker container not working for blazor server app after upgrade to pre7

After upgrading an existing blazor server app to preview7 from preview6, the docker container version does not run and fails with the following error message. The container is created, but run in debug failed with this message:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '3.0.0-preview7.19365.7' was not found.
  - The following frameworks were found:
      3.0.0-preview6.19307.2 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]

When running docker version in release mode, I see in the console log that still preview6 files are loaded:

[...]
Microsoft.Hosting.Lifetime: Information: Now listening on: https://

Microsoft.Hosting.Lifetime: Information: Now listening on: http://

      Application started. Press Ctrl+C to shut down.
Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.

      Hosting environment: Development
Microsoft.Hosting.Lifetime: Information: Hosting environment: Development

      Content root path: /app
Microsoft.Hosting.Lifetime: Information: Content root path: /app
"/usr/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview6-27804-01/System.Net.Security.dll" wurde geladen. Das Laden von Symbolen wurde 眉bersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"/usr/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview6-27804-01/System.Collections.NonGeneric.dll" wurde geladen. Das Laden von Symbolen wurde 眉bersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"/usr/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview6-27804-01/System.Runtime.Intrinsics.dll" wurde geladen. Das Laden von Symbolen wurde 眉bersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://localhost:44356/  
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/2 GET https://localhost:44356/  
"/usr/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview6-27804-01/System.Security.Principal.dll" wurde geladen. Das Laden von Symbolen wurde 眉bersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
"/usr/share/dotnet/shared/Microsoft.NETCore.App/3.0.0-preview6-27804-01/System.ComponentModel.Annotations.dll" wurde geladen. Das Laden von Symbolen wurde 眉bersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
[...]

latest Visual Studio Preview .net SDK has been installed and dependencies have been upgraded to preview7 nuget packages. App is running fine as .net core and IIS, but not with docker from visual studio. Worked with preview6 without any problem.

Here is my local dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012821
 Commit:    6348f1068a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview7-012821\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

.NET Core SDKs installed:
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.1.604 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.1.800-preview-009696 [C:\Program Files\dotnet\sdk]
  2.1.800 [C:\Program Files\dotnet\sdk]
  2.2.300 [C:\Program Files\dotnet\sdk]
  2.2.400-preview-010219 [C:\Program Files\dotnet\sdk]
  2.2.400 [C:\Program Files\dotnet\sdk]
  3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

How to reproduce

The same happens with a fresh project from an included template:

  • Using the balzor server app template
  • add docker support in visual studio
  • run the app via docker from visual studio

dockkerfile for template from balzor server project

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["WebApplication3test/WebApplication3test.csproj", "WebApplication3test/"]
RUN dotnet restore "WebApplication3test/WebApplication3test.csproj"
COPY . .
WORKDIR "/src/WebApplication3test"
RUN dotnet build "WebApplication3test.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "WebApplication3test.csproj" -c Release -o /app

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

Most helpful comment

I was able to solve the error by updating the created dockerfile manully to pull the correct images:

Changed: FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base

To: FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0-preview7-buster-slim AS base

and

Changed: FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build

To: FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview7-buster AS build

Not sure why I needed to change these tags in the dockerfile from the template but afterwars the error is gone.

All 5 comments

I was able to solve the error by updating the created dockerfile manully to pull the correct images:

Changed: FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base

To: FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0-preview7-buster-slim AS base

and

Changed: FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build

To: FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview7-buster AS build

Not sure why I needed to change these tags in the dockerfile from the template but afterwars the error is gone.

@richlander ?

@whentotrade thanks man , that is really fixed my issue.
NOTE: that issue show up after dotnet3.0 preview5 Release
EDIT: i am getting new error (only i updated versions to pre7) The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects.

I ran into this issue as well and this is how I resolved it. For anyone stumbling upon this problem, the template has not been changed but the Docker tags have. You need to match the .Net Core SDK version you are building with in your csproj file. I recommend just skipping the preview tags in docker. For me 3.0 is an official release as of September 23, 2019 and using the major and minor version will keep you up to date during patch releases as I ran into issues between 3.0.100 official release which is my SDK version and the default docker was targeting 3.0.0.

Based on https://hub.docker.com/_/microsoft-dotnet-core-sdk/
Using the major and minor version:

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build

Preview releases can also have the preview tag dropped as well. Currently 3.1 is in preview as of this comment and can be written:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build

Based on https://hub.docker.com/_/microsoft-dotnet-core-aspnet/
Same goes for the runtime as well:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS build

or

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS build

@Kavinci's solution fixed the problem for me.

Was this page helpful?
0 / 5 - 0 ratings