-
Notifications
You must be signed in to change notification settings - Fork 6
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 AD0001: Could not load file or assembly 'NetFabric.CodeAnalysis, Version=4.1.0.0' #73
Comments
@robinvanpoppel Could you try adding a package reference to Using .NET CLI, you can achieve this with the following command line:
You may then need to run a restore:
|
@aalmada Looks like the NuGet package is missing a dependency on |
@xtqqczze Sounds like that is causing this issue. Thanks for investigating! |
Is a fix planned? Or can I help out by supplying a PR? |
@robinvanpoppel Did adding a package reference to |
I did not try that because you mentioned the nuget package was missing a dependency. I can of course try it as a workaround but since |
+1 Adding a package reference to NetFabric.CodeAnalysis does not resolve the error, had to roll back to v2.0.4 to use the analyzer. Looks like this commit is where the change occurred 5fbcf3d#diff-6745205804bf0b3ec6066749eb78fa56e335a98bae48d20cf48e12c6861dfb20 The package was moved to .Package.csproj and no longer has a reference to NetFabric.CodeAnalysis or the ILRepack section |
@DavidTCarpenters Did you make sure to |
I did yeah @xtqqczze |
cc: @aalmada |
Hi all, |
Hello, I want to express my gratitude to @robinvanpoppel for contributing to pull request #76. This should hopefully resolve the dependency issue. I've released a new version, available both on NuGet and the Visual Studio Marketplace. During my sabbatical, I plan to allocate some of my time to enhance and expand the rules within this analyzer. Additionally, I've been sharing articles related to this on my LinkedIn profile: LinkedIn Articles. I'm eager to hear about your experiences with the analyzer. For now, I'll keep this issue open. Please share your feedback. |
Hi all, I've pulled the latest and I'm afraid the issue still appears to be present, with the following warning displayed: warning AD0001: Analyzer 'NetFabric.Hyperlinq.Analyzer.NonDisposableEnumeratorAnalyzer' threw an exception of type 'System.TypeLoadException' with message 'Could not load type 'NetFabric.CodeAnalysis.Errors' from assembly 'NetFabric.CodeAnalysis, Version=5.1.0.0, Culture=neutral, PublicKeyToken=null'.'. |
@DavidTCarpenters Thank you for the feedback I'm going to give assembly merging another shot. Here's a compilation of assembly merger options I've come across:
|
In attempt #77, I experimented with dnMerge but encountered an issue where the resulting assembly still had dependencies on NetFabric.CodeAnalysis. Subsequently, in attempt #78, I employed ILRepack.MSBuild.Task, which functioned as expected on my local environment. However, when integrated with GitHub actions, it failed to build successfully. I had previously reported this issue in the following GitHub repository: gluck/il-repack#273. |
ILLink (trimming) appears to be the current "official" solution, with other alternatives either abandoned or in maintenance mode. I'm inclined to investigate this new solution further. |
@aalmada Unfortunately trimming doesn't appear to work for projects targeting .NET Standard. Additionally, starting in the .NET 8 SDK, trimming is unsupported for any version of .NET Standard or .NET Framework. https://learn.microsoft.com/dotnet/core/compatibility/sdk/8.0/trimming-unsupported-targetframework |
@xtqqczze Appreciate it! It's quite unfortunate, though, as I'm encountering problems with all the other options. |
@aalmada Does anything like this work:
See https://til.cazzulino.com/msbuild/how-to-include-package-reference-files-in-your-nuget-package |
@xtqqczze, I'm grateful for your valuable suggestion! In the context of NuGet packages, it's a common practice for them to extract their dependencies into the same directory as the executable. When it comes to analyzers, the executable in question is Roslyn, and it needs to locate the required assemblies. Inside the .csproj file, there is a target named The pull request (PR) submitted by @robinvanpoppel aimed to install the dependency into this same folder. However, a significant concern arises in this scenario - there's no versioning for these assemblies. What if another analyzer relies on the same assembly but with a different version? That's why I created the NetFabric.CodeAnalysis package, designed to be reusable by other analyzers or source generators. The solution to this versioning challenge comes in two parts. One approach involves copying the source code into the analyzer itself, although I'm currently hesitant to pursue this option. The alternative, which is more ideal, is to merge the assemblies. This would make the dependencies disappear while still maintaining the independence of the projects. The success of the second solution largely depends on the effectiveness of at least one of the assembly mergers. At present, ILRepack is functioning smoothly on my local setup, and I can release a new package. However, this results in the loss of GitHub CI. I remain hopeful that either ILRepack or dnMerge will ultimately resolve this issue. |
I have just released version 2.3.0, and I genuinely hope that this resolves the problem. I deeply apologize for any inconvenience this may have caused. |
Hi Antão, No need to apologise! Thank you for all of your work on this. I have managed to get this to build locally and produce a package that I can reference in another project without using ILRepack. I'll fork the repo and submit a PR so that you can review, maybe this helps. I'll bump the version to 2.3.1 |
This really does feel like a dark art though the whole nuget distribution of analysers with dependencies. |
Add a package reference to NetFrabric.CodeAnalysis - Gets the dll into the build Include PackDependencies target - Adds the reference to the lib and analyzer Add all output dlls as analyzer references
PR is here #80 |
More than a year later I've come because I'm bitten by this issue. Is there still no remedy? |
When upgrading from 2.0.4 to 2.1.0 my builds start failing with multiple occurences of the following error message:
CSC : error AD0001: Analyzer 'NetFabric.Hyperlinq.Analyzer.AssignmentBoxingAnalyzer' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'NetFabric.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'.
. Most of the projects are targeting net48.The text was updated successfully, but these errors were encountered: