0

Running dotnetCore 2.2 I have a clr.dll dependency in my .Logic library. This clr.dll calls unmanaged.dll that I cannot load as a dependency and instead have to just copy do the bin like this.

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\myApp.Models\myApp.Models.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="CLR">
      <HintPath>..\Dependencies\NonNuget\CLR.dll</HintPath>
    </Reference>
  </ItemGroup>

  <ItemGroup>
    <None Update="unmanaged.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

my docker file looks like this:

   #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
WORKDIR /src
COPY ["myApp.Api/myApp.Api.csproj", "myApp.Api/"]
COPY ["myApp.logic/myApp.logic.csproj", "myApp.logic/"]
COPY ["myApp.Models/myApp.Models.csproj", "myApp.Models/"]
RUN dotnet restore "myApp.Api/myApp.Api.csproj"
COPY . .
WORKDIR "/src/myApp.Api"
RUN dotnet build "myApp.Api.csproj" -c Release -o /app

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

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

**When I run the api outside docker it works fine. **

When I create a docker image and run the api I end up with

System.DllNotFoundException: Unable to load DLL 'unmanaged.dll'

I assumed the file was somehow not being included in my docker image but when i run docker exec -it myapp I can see the file is present

         146 appsettings.Development.json
         105 appsettings.json
    **3,426,680 unmanaged.dll**
     239,429 myApp.Api.deps.json
      13,824 myApp.Api.dll
       2,696 myApp.Api.pdb
         252 myApp.Api.runtimeconfig.dev.json
         224 myApp.Api.runtimeconfig.json
       1,188 myApp.logic.deps.json
       5,120 myApp.logic.dll
         632 myApp.logic.pdb
       1,459 myApp.Models.deps.json
       4,608 myApp.Models.dll
         708 myApp.Models.pdb
       **5,120 clr.dll**

I could really use some advice as I am very new to docker and not sure where to go from here.

macm
  • 544
  • 7
  • 21
  • Did you try to run it inside Windows Server Core container? It seems to be your base is nano server which does not have Full .NET framework which I assume your dependency needs – Gregory Suvalian Jan 04 '19 at 21:55
  • My guess why it isn't working is the unmanaged DLL has dependencies to the windows gac which are not present in the 2.2 SDK. This is why I can dotnet run the published project but not run the exact same container app. Does that make sense? – macm Jan 06 '19 at 00:00
  • Did you try to run it inside Windows Server Core container? It seems to be your base is nano server which does not have Full .NET framework which I assume your dependency needs – Gregory Suvalian Jan 06 '19 at 00:09

0 Answers0