Describe the bug
When using MacOS, the nx dependency graph does not show dependencies on class libraries from apps.
To Reproduce
Steps to reproduce the behavior:
- Create workspace
- Create console application (
nx generate @nx-dotnet/core:app Demo.App)
- Create class library (
nx generate @nx-dotnet/core:lib Demo.Lib)
- Using an IDE, create a class in Demo.Lib and consume it in Demo.App - ensure the IDE adds a project reference from Demo.App to Demo.Lib.
- Look at the dependency graph (
nx dep-graph)
Expected behavior
The dependency graph should show a dependency on Demo.Lib from Demo.App.
Environment:
- OS: MacOS
- DotNet SDK: 5.0.100
Additional context
After some investigation, this problem appears to be caused by the fact that the DotNet CLI writes project reference paths into the *.csproj files using backslashes, for example:
<ItemGroup>
<ProjectReference Include="..\..\libs\demo.lib\DemoLib.csproj" />
</ItemGroup>
If you manually edit the *.csproj file and convert the backslashes to forward slashes, then the dependency graph works as expected:
<ItemGroup>
<ProjectReference Include="../../libs/demo.lib/DemoLib.csproj" />
</ItemGroup>
Strangely, if you create a unit test project for the app when prompted by nx, then the dependency from the test project to the app works fine despite the use of backslashes - maybe this works because it doesn't have to go up a folder to the libs folder?:
<ItemGroup>
<ProjectReference Include="..\demo.app\DemoApp.csproj" />
</ItemGroup>
It looks like the DotNet CLI creates project references with backslashes; I wonder whether there's an issue with how resolve is calculating the paths here: https://github.com/nx-dotnet/nx-dotnet/blob/master/packages/utils/src/lib/utility-functions/workspace.ts#L60
Describe the bug
When using MacOS, the nx dependency graph does not show dependencies on class libraries from apps.
To Reproduce
Steps to reproduce the behavior:
nx generate @nx-dotnet/core:app Demo.App)nx generate @nx-dotnet/core:lib Demo.Lib)nx dep-graph)Expected behavior
The dependency graph should show a dependency on Demo.Lib from Demo.App.
Environment:
Additional context
After some investigation, this problem appears to be caused by the fact that the DotNet CLI writes project reference paths into the *.csproj files using backslashes, for example:
If you manually edit the *.csproj file and convert the backslashes to forward slashes, then the dependency graph works as expected:
Strangely, if you create a unit test project for the app when prompted by nx, then the dependency from the test project to the app works fine despite the use of backslashes - maybe this works because it doesn't have to go up a folder to the libs folder?:
It looks like the DotNet CLI creates project references with backslashes; I wonder whether there's an issue with how
resolveis calculating the paths here: https://github.com/nx-dotnet/nx-dotnet/blob/master/packages/utils/src/lib/utility-functions/workspace.ts#L60