2

I have a net7 worker service, which works as expected with the default implementation from the template.

I want this service to run a job, and do somethin in a sql server database. This is another library and when running the workerservice on my host via visual studio ide, it does not complain of anything.

However, when I try to build the image, the image gets buidl but when I run this image I'm getting

im-svc exited with code 150
im-svc  | No frameworks were found.
im-svc  |
im-svc  | Learn about framework resolution:
im-svc  | https://aka.ms/dotnet/app-launch-failed
im-svc  |
im-svc  | To install missing framework, download:
im-svc  | https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=7.0.0&arch=x64&rid=debian.11-x64
im-svc  | You must install or update .NET to run this application.
im-svc  |
im-svc  | App: /app/Svc.InventoryManagement.dll
im-svc  | Architecture: x64
im-svc  | Framework: 'Microsoft.AspNetCore.App', version '7.0.0' (x64)
im-svc  | .NET location: /usr/share/dotnet/
im-svc  |
im-svc  | No frameworks were found.
im-svc  |
im-svc  | Learn about framework resolution:
im-svc  | https://aka.ms/dotnet/app-launch-failed
im-svc  |
im-svc  | To install missing framework, download:
im-svc  | https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=7.0.0&arch=x64&rid=debian.11-x64

Not only that , but I've removed any code that may get executed, and only left the .dll reference and still same issue.

If I remove the reference from this library, the container running this service runs as expected

FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["./Svc.InventoryManagement/Svc.InventoryManagement.csproj", "Svc.InventoryManagement/"]
RUN dotnet restore "Svc.InventoryManagement/Svc.InventoryManagement.csproj"
COPY . .
WORKDIR "/src/Svc.InventoryManagement"
RUN dotnet build "Svc.InventoryManagement.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Svc.InventoryManagement.csproj" -c Release -o /app/publish /p:UseAppHost=false

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

Referenced library :

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\lib.Utils\lib.Utils.csproj" />
    </ItemGroup>

</Project>

Inner referenced

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <FrameworkReference Include="Microsoft.AspNetCore.App" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
    </ItemGroup>

    <ItemGroup>
      <Folder Include="EnumExtensions\" />
    </ItemGroup>

</Project>

Note : I have a net7 API which uses the same library and when running in docker it runs as expected.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132

1 Answers1

0

It seems that your "Inner" project requires ASP.NET Core Runtime. Change FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base to FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base (@hub.docker) or remove the FrameworkReference element from corresponding .csproj.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132