Skip to content

chore: Remove unneeded project reference from auto-generated project#3171

Open
filzrev wants to merge 1 commit into
dotnet:masterfrom
filzrev:chore-remove-unneeded-project-reference
Open

chore: Remove unneeded project reference from auto-generated project#3171
filzrev wants to merge 1 commit into
dotnet:masterfrom
filzrev:chore-remove-unneeded-project-reference

Conversation

@filzrev

@filzrev filzrev commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR remove ProjectReference of benchmark project from BenchmarkDotNet.Autogenerated.csproj

CsProjGenerator gather referenced dlls of benchmark project.
Then add referenced dlls as <Reference Include="..." /> node.

So original <ProjectReference Include="..." /> node is not expected to be used when building BenchmarkDotNet.Autogenerated.csproj

Test
This code path is not used when running IntegrationTest project or when using non Release custom configuration.

public async Task<BuildResult> RestoreThenBuildAsync(CancellationToken cancellationToken = default)

So I've confirmed behavior by using generated binlog.
After this PR content is merged. Reference project evaluation stage is skipped on local build.

@timcassell

timcassell commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

When I tried it originally the disassemble tests failed. Maybe that was fixed with clrmd v4. [Edit] Actually, I see the tests are still failing on arm.

@filzrev

filzrev commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Disassembler tests on linux(arm64)/macos(arm64) failed with following error.

System.DllNotFoundException: Unable to load shared library 'capstone' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: 
dlopen(/Users/runner/work/BenchmarkDotNet/BenchmarkDotNet/.dotnet/shared/Microsoft.NETCore.App/8.0.27/capstone.dylib, 0x0001):
(...Fallback to available system paths...)

It's occurred because DllGatherer add <Reference> node for DLLs.
And if ProjectReference is removed. Generated deps.json file don't contains runtimeTargets.
So it failed to resolve native dependencies.

And as far as I've confirmed.
It require hacky MSBuild operations to add these dependencies with GenerateBuildDependencyFile hook.
e.g. https://www.nuget.org/packages/Asmichi.InjectNativeFileDepsHack

@timcassell
May I ask what's the purpose of adding <Reference> tag on AutoGenerated project? (#2508/#2921)
If it's introduced for DLL copy related issue. It might be resolved by another approach.

@timcassell

Copy link
Copy Markdown
Collaborator

It's to resolve issues with dll references that weren't picked up by the auto-generated project previously (see the linked issues that #2508 closed). If you have a better solution for it, please send a PR. 😄

@timcassell

Copy link
Copy Markdown
Collaborator

I see the reference gatherer only gets the top directory files, not nested directories. Maybe we simply need to pass SearchOption.AllDirectories to fix it.

foreach (var assemblyFile in Directory.GetFiles(artifactsPaths.BinariesDirectoryPath, "*.dll"))

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants