question

BeckerChristian-2831 avatar image
0 Votes"
BeckerChristian-2831 asked DanielZhang-MSFT commented

Replacing Microsoft.NetCore.Analyzers in .NET 5

Hi There,

when migrating from netcoreapp3.1 to net5.0 deprecation messages for Microsoft.NetCore.Analyzers and Microsoft.CodeAnalysis.Analyzers appears:

CSC : warning CA9998: FxCopAnalyzers package has been deprecated in favor of 'Microsoft.CodeAnalysis.NetAnalyzers', that ships with the .NET SDK.

So I've removed the nugets and add

<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>

to <PropertyGroup> in csproj file.

But when executing dotnet build I only see 15 warnings while I see 125 warnings when enabling the deprecated nugets.

How can I get the messages back?

Bests
Chris




dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BeckerChristian-2831,
May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.
Best Regards,
Daniel Zhang

0 Votes 0 ·

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered DanielZhang-MSFT commented

Hi BeckerChristian-2831,
Please add the following XML node into the project file to reference the package.

 <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
   <PrivateAssets>all</PrivateAssets>
   <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
 </PackageReference>

More details please refer to this link.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

But this is activating the old / deprecated Analyzers.

0 Votes 0 ·

Hi @BeckerChristian-2831,
Microsoft.NetCore.Analyzers has been deprecated instead of Microsoft.CodeAnalysis.Analyzers.
Best Regards,
Daniel Zhang

0 Votes 0 ·