Azure / iotedgedev

The Azure IoT Edge Dev Tool greatly simplifies your Azure IoT Edge development process. It has everything you need to get started and helps with your day-to-day Edge development.
https://aka.ms/iotedgedev
Other
160 stars 70 forks source link

How to debug module filtermodule created by ioteddev solution init? #620

Open RollsChris opened 9 months ago

RollsChris commented 9 months ago

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 commented 9 months ago

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

konichi3 commented 9 months ago

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

RollsChris commented 9 months ago

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