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

"Error CS8034: failed to load Analyzer", if analyzer is packed with native dependencies #63396

Closed
Sergio0694 opened this issue Aug 14, 2022 · 2 comments
Labels
Area-Analyzers Area-Compilers Resolution-Duplicate The described behavior is tracked in another issue

Comments

@Sergio0694
Copy link
Contributor

Version Used: VS17.3

Steps to Reproduce:

  1. Checkout to Sergio0694/ComputeSharp@84badb3

OR

  1. Create a new analyzer
  2. Bundle a native .dll in some subfolder (eg. analyzers\dotnet\cs\Libraries\x64\foo.dll)
  3. Create a NuGet package for the analyzer
  4. Reference that from a project
  5. Try to build the project

Expected Behavior:

The analyzer should work just fine and Roslyn should ignore those bundled native libs (as they're not assembly references).

Actual Behavior:

CSC : error CS8034: Unable to load Analyzer assembly C:\Users\runneradmin.nuget\packages\computesharp\2.0.0-alpha.2855646720\analyzers\dotnet\cs\Libraries\arm64\dxcompiler.dll : PE image doesn't contain managed metadata. [D:\a\ComputeSharp\ComputeSharp\tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj]

Additional context:

This is me trying to follow up on #63290 and the conversation I had with @CyrusNajmabadi, and doing work to stop doing IO from my generator in ComputeSharp (see Sergio0694/ComputeSharp#349). Currently, I'm bundling two native .dll-s as embedded resources, and then extracting them into a temp folder to load them and P/Invoke into them. The PR is changing that to instead pack those libraries with the analyzer, so they're copied in a subdirectory in the analyzer folder, from where I can load them directly (without additional IO).

For some reason though, Roslyn is trying to load those .dll-s automatically, and then failing due to them being native libs.

Questions:

  1. Is there a way to get Roslyn to ignore those files so it doesn't fail to load the analyzer?
  2. Can we document this scenario, "bundling native dependencies in a generator", so it's easier to setup for others too?

cc. @sharwell @chsienki

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 14, 2022
@dibarbet
Copy link
Member

possible dupe of #54899

@Sergio0694
Copy link
Contributor Author

Yeah this seems like a duplicate indeed, closing this one 🙂

@Sergio0694 Sergio0694 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2022
@sharwell sharwell added Resolution-Duplicate The described behavior is tracked in another issue and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers Area-Compilers Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

3 participants