iotedgedev icon indicating copy to clipboard operation
iotedgedev copied to clipboard

How to debug module filtermodule created by ioteddev solution init?

Open RollsChris opened this issue 1 year ago • 3 comments

I am having the same issue trying to debug my module inside the simulator.

The filtermodule doesn't have the Dockerfile.windows-amd64.debug file when created with the iotedgedev solution init and running dotnet publish --os linux --arch x64 /t:PublishContainer seems to create a production ready container without vsdbg installed

im on a windows machine with linux containers, im actually developing inside the iotedgedev container with the simulator running with the image genearated with dotnet publish --os linux --arch x64 /t:PublishContainer ...

when i f5 i get:

Starting: "docker" exec -i filtermodule sh -c "~/vsdbg/vsdbg --interpreter=vscode" Error from pipe program 'docker': sh: 1: /home/app/vsdbg/vsdbg: not found The pipe program 'docker' exited unexpectedly with code 127.

Any ideas?

thank you

RollsChris avatar Feb 23 '24 00:02 RollsChris

It seems like you still need to use the Dockerfile and module.json files to get it debugging:

Dockerfile

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

RUN apt-get update
RUN apt install -y curl
RUN apt-get install -y --no-install-recommends unzip procps
RUN rm -rf /var/lib/apt/lists/*

RUN useradd -ms /bin/bash moduleuser
USER moduleuser
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Debug -o out

FROM base
WORKDIR /app
COPY --from=build-env /app/out ./

ENTRYPOINT ["dotnet", "app.dll"]

module.json

{
    "$schema-version": "0.0.1",
    "description": "",
    "image": {
        "repository": "localhost:5000/app",
        "tag": {
            "version": "0.0.1",
            "platforms": {
                "amd64": "./Dockerfile.amd64", 
                "amd64.debug": "./Dockerfile.amd64.debug"
            }
        },
        "buildOptions": []
    },
    "language": "csharp"
}

then when you run the command:

iotedgedev simulator start -b -f deployment.debug.v6.template.json

I think it looks at the module.json and builds the dockerfile.

This should now allow you to use f5 for debugging.

Hope this helps someone else Thanks

RollsChris avatar Feb 26 '24 09:02 RollsChris

We recommend using IoT Edge runtime to debug your edge module. Instrustuction here.

konichi3 avatar Feb 27 '24 20:02 konichi3

We recommend using IoT Edge runtime to debug your edge module. Instrustuction here.

This links to the iotedge extension method which Is in maintenance and the cli method seems out of date and what I tried to follow originally

RollsChris avatar Feb 27 '24 20:02 RollsChris