Open jvskriubakken opened 6 months ago
I've not experienced this, is it possible that you are running commands from other directories than the workspace root? That shouldn't matter, but would be nice to rule out.
All commands are run from workspace/repo root.
webapp project.json:
{
"name": "firefly-my-chimney-webapi-cs",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/firefly/my-chimney/webapi-cs",
"implicitDependencies": ["firefly-my-chimney-client-ts"],
"targets": {
"build": {
"executor": "@nx-dotnet/core:build",
"outputs": ["{options.output}"],
"options": {
"configuration": "Debug",
"noDependencies": false
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"serve": {
"executor": "@nx-dotnet/core:serve",
"options": {
"configuration": "Debug"
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"serve-production": {
"executor": "@nx-dotnet/core:serve",
"options": {
"configuration": "Debug",
"launch-profile": "Production"
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"lint": {
"executor": "@nx-dotnet/core:format"
},
"format": {
"executor": "@nx-dotnet/core:format",
"options": {
"fix": true
}
},
"publish": {
"executor": "@nx-dotnet/core:publish",
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"publish-to-pipeline": {
"executor": "@airmont/nx-plugins:publish-pipeline-artifact",
"options": {
"dotNetVersion": "net8.0"
}
}
},
"tags": ["dotnet"]
}
is it correct to have "noDependencies": false
here?
webapp csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>7813e2b2-f546-44d9-bf13-ca8b6ecf45df</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.7" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\libs\firefly\my-chimney\cs\service\service.csproj" />
<ProjectReference Include="..\..\..\..\libs\firefly\my-chimney\cs\Ef\Ef.csproj" />
<ProjectReference Include="..\..\..\..\libs\Firefly\shared\cs\Firefly.Core.Application.Web\Firefly.Core.Application.Web.csproj" />
<ProjectReference Include="..\..\..\..\libs\firefly\my-chimney\cs\domain\domain.csproj"/>
<ProjectReference Include="..\..\..\..\libs\Firefly\shared\cs\Firefly.Provisioning.Services\Firefly.Provisioning.Services.csproj" />
<ProjectReference Include="..\..\..\..\libs\Firefly\shared\cs\Firefly.Storage.DocumentDb\Firefly.Storage.DocumentDb.csproj" />
<ProjectReference Include="..\..\..\..\libs\Firefly\shared\cs\Firefly.Storage.KeyVault\Firefly.Storage.KeyVault.csproj" />
</ItemGroup>
<ItemGroup>
<Content Remove="project.json" />
<None Include="project.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
... here you can see that the dependency Firefly.Core.Application.Web.csproj
is listed.
Here you have firefly-shared-cs-core-web-application:
{
"name": "firefly-shared-cs-core-web-application",
"$schema": "../../../../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/firefly/shared/cs/Firefly.Core.Application.Web",
"targets": {
"build": {
"executor": "@nx-dotnet/core:build",
"outputs": ["{options.output}"],
"options": {
"configuration": "Debug",
"noDependencies": true
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"test": {
"executor": "@nx-dotnet/core:test",
"options": {}
},
"lint": {
"executor": "@nx-dotnet/core:format"
},
"format": {
"executor": "@nx-dotnet/core:format",
"options": {
"fix": true
}
}
},
"tags": ["dotnet"]
}
and it's csproj :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Firefly.Core.Security\Firefly.Core.Security.csproj" />
<ProjectReference Include="..\Firefly.Core.Storage\Firefly.Core.Storage.csproj" />
<ProjectReference Include="..\Firefly.Core.Web\Firefly.Core.Web.csproj" />
<ProjectReference Include="..\Firefly.Shared.Service\Firefly.Shared.Service.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="bin\**" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="bin\**" />
</ItemGroup>
<ItemGroup>
<None Remove="bin\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.7" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
</ItemGroup>
</Project>
... are they as expected? Thinking especiallhy of noDependencies": true
?
Same issue. In my opinion it's something wrong with "noDependencies".
When I run nx build <project_name>
with below project.json
configuration:
"targets": {
"build": {
"options": {
"noDependencies": false
}
}
}
Everything works as indented. This runs: dotnet "build" "/home/x/y/z.csproj" "--configuration" "Debug" "--verbosity" "minimal"
But when I run same command with this configuration (default one):
"targets": {
"build": {
"options": {
"noDependencies": true
}
}
}
I get error CSC : error CS0006: Metadata file
: This runs: dotnet "build" "/home/x/y/z.csproj" "--configuration" "Debug" "--no-dependencies" "--verbosity" "minimal"
.
There is something wrong with: https://www.nx-dotnet.com/docs/core/guides/incremental-builds "(...) This is not the case within Nx, due to the targetDependencies setup inside nx.json."
Are we missing some configuration in nx.json
for dotnet?
I found issue. MSBuild properties are not supported for nx
.
Example:
If in .csproj
i use relative path:
(...)
<ProjectReference Include="..\..\..\..\libs\x\x.csproj" />
Build with "--no-dependencies" works and nx graph
show everything as expected.
But when i use MSBuild properties like this:
Directory.Build.props
:
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
.csproj
:
(...)
<ProjectReference Include="$(RepoRoot)\libs\x\x.csproj" />
nx graph
show no connection with my x
library and build with "--no-dependencies" throw CSC : error CS0006: Metadata file
I have a similar issue, only happening in my CI pipeline, and the workaround is to disable NX cache.
Also, FWIW this problem started to happen after I added a new .net project to my repo. Before I already had a set of projects and everything was working fine.
UPDATE:
The comments in this thread helped. My problem was resolved by editing project.json
and changing the "noDependencies" option to false. However, it seems like in the new project this value was set to true by default. Is this expected? What is the purpose of this option?
"options": {
"configuration": "Debug",
"noDependencies": false
}
HOWEVER, we had other branches with this new project (even main) that are successfully building without the aforementioned option. So there seems to be some inconsistent behavior either with NX or with the .NET plugin for NX and it seems to be related to this option and the use of cache.
In summary:
"noDependencies": true
"noDependencies": false
Why did this problem not happen before? Why did it appear in the following branch and not on the original PR? Why disabling cache fixed the issue?
So many questions.
I hope this helps the NX team to figure out what is going on.
Other than these issues that pop from time to time (especially with the .NET plugin), we love using NX!
The reasoning for us setting noDependencies
is described here: https://www.nx-dotnet.com/docs/core/guides/incremental-builds.
The fact that skipping the cache results in things working suggests that Nx isn't capturing all of the build outputs that it should. By default, nx-dotnet sets up outputs going into {workspaceRoot}/dist/{projectRoot}
and {workspaceRoot}/dist/intermediates/{projectRoot}
. If there are outputs from your project not in those directories, they wouldn't be captured by Nx and thus not replayed from the cache.
Missing intermediates causes issues when noDependencies
is true.
I also ran into this issue and it proved quite difficult to debug. The issue is that the cloud cache was messed up (it was also missing the ref .dll) and we couldn't figure out how to clear the cache stored there. We ended up basically just using NX as we would lerna.
We wanted to use NX and its features but the reality is that it's not worth the extra headache when also working with .NET projects.
Current Behavior
Hi,
I keep on experiencing, during build that referenced assembly cannot be found. The csproj of the app has a ProjectReference to the project.
The workaround is that I have to add the referenced assembly as an implicit dependency to the app's project.json.
What could cause this? Could there any fragility in nx-dotnet's resolving of dependencies? As I understand it nx-dotnet should resolve probject dependencies automatically by inspecting csproj files?
Expected Behavior
That nx-dotnet automatically resolves dependencies from csproj-files.
Github Repo
No response
Steps to Reproduce
1.
Nx Report
nx.json
Failure Logs
Additional Information
csproj of the app (firefly-my-chimney-webapi-cs) that fails during build: