Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build module for solution with multiple projects #6606

Open
click2install opened this issue Aug 19, 2022 · 5 comments
Open

Unable to build module for solution with multiple projects #6606

click2install opened this issue Aug 19, 2022 · 5 comments

Comments

@click2install
Copy link

click2install commented Aug 19, 2022

When creating a new IoT Edge solution with a single IoTEdgeModule project with the AzureIoTEdgeApp everything works as expected.

If however, you have multiple projects in the same solution it does not build from the Dockerfile as expected due to it not having the parent directory available in its context, for example;

 -/ AzureIoTEdgeApp1
 -/ ClassLibrary1
 -/ IotEdgeModule1
 -/ AzureIoTEdgeApp1.sln

For this to work the most successful approach is to set the data context within module.json to be the root directory, i.e. the parent of the module.json and the location of the solution file as ../. This mostly works, however you end up with a warning from the dockerfile of:

/app/AzureIotEdgeApp1/AzureIotEdgeApp1.iotedgeproj : warning NU1503: Skipping restore for project '/app/AzureIotEdgeApp1/AzureIotEdgeApp1.iotedgeproj'. The project file may be invalid or missing targets required for restore. [/app/AzureIotEdgeApp1.sln]

The only approach to not encounter that warning is to have the Dockerfile (and its context) in the same folder as the module.json file. Using that approach removes the warning above, but prohibits multiple projects within a solution as the Docker context is not able to access them from the current folder.

Current Behavior

As outlined in the summary above, it's not possible to have multiple projects within an IoTEdgeModule solution and have it build within the usual flow of tooling in Visual Studio or using the Dockerfile from the shell.

Expected Behavior

A simple approach to allowing multiple projects (class libraries) within a solution and have a simple build solution.

Steps to Reproduce - Flow 1

  1. Create a new IoTEdgeModule
  2. Add a class library and link it as a project reference to the edge module
  3. Build IoT Edge Modules
  4. Dockerfile output will show Skipping project "/ClassLibrary1/ClassLibrary1.csproj" because it was not found.

Steps to Reproduce - Flow 2

  1. Create a new IoTEdgeModule
  2. Set "contextPath": "../" in module.json
  3. Add a class library and link it as a project reference to the edge module
  4. Build IoT Edge Modules
  5. Dockerfile output will show /app/AzureIotEdgeApp1/AzureIotEdgeApp1.iotedgeproj : warning NU1503: Skipping restore for project '/app/AzureIotEdgeApp1/AzureIotEdgeApp1.iotedgeproj'. The project file may be invalid or missing targets required for restore. [/app/AzureIotEdgeApp1.sln]

Is there a simple approach, or documented guidance to this workflow as it doesn't seem like an extraordinary developer experience or use case.

@click2install click2install changed the title Unable to build solution with multiple projects Unable to build module for solution with multiple projects Aug 19, 2022
@bilalsellak bilalsellak self-assigned this Aug 23, 2022
@bilalsellak
Copy link
Contributor

Investigating this

@marianan
Copy link
Contributor

@click2install thanks for reporting this issue. At this time setting the image.contextPath is the only way - https://docs.microsoft.com/en-us/azure/iot-edge/how-to-configure-module-build-options?view=iotedge-2020-11

@click2install
Copy link
Author

Thanks @marianan that's what we've done to workaround the issue (flow #2 above). The challenge that poses though is the references from the build target aren't included so we've had to include those manually (in a temporarily linked project) so there isn't a runtime exception from assembly load.

@github-actions
Copy link

This issue is being marked as stale because it has been open for 30 days with no activity.

@AlexandrStarov
Copy link

Will this bug be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants