question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In Visual studio 2017,Unable to build IoT edge module when i referencing .net core based class library in iotedge project.

See original GitHub issue

Expected Behavior

Should be able to build iotedge module when referencing class library project, in visual studio 2017

Current Behavior

In Visual studio 2017,Unable to build IoT edge module when i referencing .net core based class library in iotedge project, got error message which is given below Skipping project “/IotEdgeClassLibrary/IotEdgeClassLibrary.csproj” because it was not found. Skipping project “/IotEdgeClassLibrary/IotEdgeClassLibrary.csproj” because it was not found. Restore completed in 859.82 ms for /app/IotEdgeModule.csproj. /usr/share/dotnet/sdk/2.1.802/Microsoft.Common.CurrentVersion.targets(1875,5): warning : The referenced project ‘…/IotEdgeClassLibrary/IotEdgeClassLibrary.csproj’ does not exist. [/app/IotEdgeModule.csproj] Program.cs(13,11): error CS0246: The type or namespace name ‘IotEdgeClassLibrary’ could not be found (are you missing a using directive or an assembly reference?) [/app/IotEdgeModule.csproj] The command ‘/bin/sh -c dotnet publish -c Debug -o out’ returned a non-zero code: 1 [ERROR]: Build docker image failed:The command ‘/bin/sh -c dotnet publish -c Debug -o out’ returned a non-zero code: 1

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. Created iotedge project in visual studio 2017 using .net core 2.1.
  2. Created class library in same solution using .net core 2.1
  3. Added reference of class library in iotedge project.
  4. Right clicked on the iotedge project, selected the option Build Iotedge Modules. and got error message on output window of visual studio 2017.

Context (Environment)

IDE : Visual studio 2017 OS : Azure virtual machine(Windwos 10 version 1809) Docker/Moby [run docker version]: 2.1.0.3

Snapshot of project structure, error message, dockerfile

Dockerfile Error1 Error1Ex Solution

Error message

DOCKER_HOST: 
DOCKER_TLS_VERIFY: 
DOCKER_CERT_PATH: 
Additional Env Variables: 
------ Build IoT Edge Modules started: Platform: Linux Amd64, Configuration: Debug ------
The deployment manifest is generated at C:\Project\AzureIotEdge\AzureIotEdgeApp\config\deployment.amd64.debug.json
docker build --rm -f "C:\Project\AzureIotEdge\IotEdgeModule\Dockerfile.amd64.debug" -t previewacr.azurecr.io/iotedgemodule:0.0.1-amd64.debug  "C:\Project\AzureIotEdge\IotEdgeModule"
Sending build context to Docker daemon  668.2kB
Step 1/15 : FROM microsoft/dotnet:2.1-runtime-stretch-slim AS base
 ---> 43005d15cfda
Step 2/15 : RUN apt-get update &&     apt-get install -y --no-install-recommends unzip procps &&     rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> aee8bbf234b6
Step 3/15 : RUN useradd -ms /bin/bash moduleuser
 ---> Using cache
 ---> 5ee8caa96715
Step 4/15 : USER moduleuser
 ---> Using cache
 ---> 3062483c6592
Step 5/15 : RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
 ---> Using cache
 ---> a1e434090582
Step 6/15 : FROM microsoft/dotnet:2.1-sdk AS build-env
 ---> bf77a711b92c
Step 7/15 : WORKDIR /app
 ---> Using cache
 ---> c70a58309537
Step 8/15 : COPY *.csproj ./
 ---> Using cache
 ---> dcf50d920034
Step 9/15 : RUN dotnet restore
 ---> Using cache
 ---> 4117095b00bd
Step 10/15 : COPY . ./
 ---> Using cache
 ---> 392a1fe535f6
Step 11/15 : RUN dotnet publish -c Debug -o out
 ---> Running in d3384e97e8df
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Skipping project "/IotEdgeClassLibrary/IotEdgeClassLibrary.csproj" because it was not found.
  Skipping project "/IotEdgeClassLibrary/IotEdgeClassLibrary.csproj" because it was not found.
  Restore completed in 859.82 ms for /app/IotEdgeModule.csproj.
/usr/share/dotnet/sdk/2.1.802/Microsoft.Common.CurrentVersion.targets(1875,5): warning : The referenced project '../IotEdgeClassLibrary/IotEdgeClassLibrary.csproj' does not exist. [/app/IotEdgeModule.csproj]
Program.cs(13,11): error CS0246: The type or namespace name 'IotEdgeClassLibrary' could not be found (are you missing a using directive or an assembly reference?) [/app/IotEdgeModule.csproj]
The command '/bin/sh -c dotnet publish -c Debug -o out' returned a non-zero code: 1
[ERROR]: Build docker image failed:The command '/bin/sh -c dotnet publish -c Debug -o out' returned a non-zero code: 1

Additional Information

Please provide any additional information that may be helpful in understanding the issue.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
SLdragoncommented, Oct 23, 2019

This error is because your dotnet publish command cannot find the project file in the root folder. To help you better understanding how to change the Dockfile, here is a sample docker file you can refer:

FROM microsoft/dotnet:2.1-runtime-stretch-slim AS base

RUN apt-get update && \
    apt-get install -y --no-install-recommends unzip procps && \
    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 microsoft/dotnet:2.1-sdk AS build-env
WORKDIR /app

COPY ./IotEdgeModule1/*.csproj ./
RUN dotnet restore

COPY . ./

RUN dotnet publish "IotEdgeModule1/IotEdgeModule1.csproj" -c Debug -o out 

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

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

image

I aslo created a sample project, you can find it here: SampleEdgeProjectWithCSharpLibary.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to build module for solution with multiple projects
Steps to Reproduce - Flow 1. Create a new IoTEdgeModule; Add a class library and link it as a project reference to the...
Read more >
Develop IoT Edge modules using Visual Studio Code
This tutorial walks through setting up your development machine and cloud resources to develop IoT Edge modules.
Read more >
Develop module for Linux devices using Azure IoT Edge ...
Use Visual Studio 2019 to develop, debug and deploy code to devices running IoT Edge for Linux on Windows. This tutorial walks through ......
Read more >
Troubleshoot Azure IoT Edge common errors
Resolve common issues encountered when using an IoT Edge solution. ... The Set modules functionality in Azure portal or Create deployment ...
Read more >
Develop and debug Azure IoT Edge modules using Visual ...
This article shows you how to use Visual Studio 2022 to develop, debug, and deploy custom Azure IoT Edge modules. Visual Studio 2022 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found