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

Running built-in Roslyn analyzer fails build in Visual Studio 2022 #85

Closed
murlakatam opened this issue Nov 8, 2023 · 0 comments · Fixed by #86
Closed

Running built-in Roslyn analyzer fails build in Visual Studio 2022 #85

murlakatam opened this issue Nov 8, 2023 · 0 comments · Fixed by #86

Comments

@murlakatam
Copy link
Contributor

image
Got

AD0001 Analyzer 'Conventional.Roslyn.Analyzers.IfAndElseMustHaveBracesAnalyzer' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'.

'Conventional.Roslyn.Analyzers.UsingsStatementsMustNotBeNestedAnalyzer' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'.

in latest visual studio 2022 Version 17.7.6 (but works fine in Rider)

Workaround:
Configure project to stop using analyzers in live mode or on build
image
image

Question to owner:

Perhaps its time to upgrade from dotnet standard to .net 6 as well @andrewabest, or multi target to all LTS versions atm, including .netStandard2.1?

Reasoning: to be able to run those analysers in life analysis mode or on build those analysers dll must target the same target framework as the project that is pulling the nuget package.

I can make that change if you are OK with this proposed solution...

https://github.com/andrewabest/Conventional/blob/14c7302594621c3b1b628067612a7f4ec16a3857/src/Roslyn/Conventional.Roslyn.Analyzers/Conventional.Roslyn.Analyzers.csproj#L4C6-L4C6

  <PropertyGroup>
        <TargetFrameworks>netstandard2.1;net6.0;net7.0</TargetFrameworks>
        <EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
    </PropertyGroup>

for both Roslyn and Analyzers projects.

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 a pull request may close this issue.

1 participant