1

We are trying to build an iot edge module on windows 1809. Our Project folder hierarchy is as follows:

----BaseDir
    |---ClassLibrary1

    |---ClassLibrary2
        |--references ClassLibrary1
        |--references ClassLibrary3

    |---ClassLibrary3
         |--references ClassLibrary4
         |--references ClassLibrary1

    |---ClassLibrary4

    |---OurIOTEdgeModule
        |--references ClassLibrary2

Our docker file looks like this:

FROM microsoft/dotnet:2.1-sdk AS build-env
WORKDIR /app
COPY *.csproj ./
COPY ./NuGet.Config ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM microsoft/dotnet:2.1-runtime-nanoserver-1809
WORKDIR /app
COPY --from=build-env /app/out ./
ENTRYPOINT ["dotnet", "IOTEdgeModule.dll"]

When we build this IOT Edge Module we are not getting any build errors. When we deploy the module on the EDGE device, we are facing the issue.

Our IOTEdgeModule is referencing ClassLibrary2.csproj. ClassLibrary2 inturn is referencing ClassLibrary3.csproj which in turn is referencing ClassLibrary4.csproj. Our IOT Edge module is only able to get the reference of ClassLibrary2.csproj but failing to refer all other dependant *.csprojs.

How to modify the docker file to solve this issue? Suggestions would be much appreciated.

Harshith R
  • 418
  • 1
  • 11
  • 31
  • `dotnet publish` on docker is failing? What error do you get there? – Chetan Sep 16 '19 at 11:26
  • @ChetanRanpariya While building it skips referencing those .csproj. After build and push, it doesn't throw any exception but the edge module stops working. – Harshith R Sep 16 '19 at 11:32
  • Did you compare the output of dotnet publish from docker and local machine? You have all the csproj files available in /app folder? – Chetan Sep 16 '19 at 11:38

1 Answers1

2

This is not possible with the dockerfiles provided by the IoT Edge templates. The official IoT Edge repo has examples with the same structure. Instead of building inside a docker container, they build outside and only copy the built binaries into the final image. See this example project file and the corresponding Dockerfile:

ARG base_tag=2.1.10-alpine3.7
FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag}

ARG EXE_DIR=.

ENV MODULE_NAME "SimulatedTemperatureSensor.dll"

WORKDIR /app

COPY $EXE_DIR/ ./

# Add an unprivileged user account for running the module
RUN adduser -Ds /bin/sh moduleuser 
USER moduleuser

CMD echo "$(date --utc +"[%Y-%m-%d %H:%M:%S %:z]"): Starting Module" && \
    exec /usr/bin/dotnet SimulatedTemperatureSensor.dll

Update: There is a solution to a similar issue here.

silent
  • 14,494
  • 4
  • 46
  • 86