Some projects' dependencies contain unexplaine

2019-07-22 09:12发布

I have a couple of projects where under Dependencies there are one or two branches of code analyzers like this:

enter image description here

I tried the right mouse click on every branch as explaind here but there is no option to configure them and I also searched for *.ruleset files insinde the solution, I also check the packages as shown in the docs but there is nothing like that anywhere.

There is also nothing suspicious in the .csproj files, just some nuget packages that I've installed but nothing analyzer related.

How do I get rid of them? They give me warnings when I reference such projects in other solutions and nuget restore doesn't fix it either:

enter image description here

I have no idea where they come from. Some projects have them and others don't. However, they seem to somehow be related to ASP.NET Core or MVC packages that are installed in those projects.

2条回答
时光不老,我们不散
2楼-- · 2019-07-22 09:40

I've fixed the warnings by deleting the microsoft.codeanalysis.analyzers folder and executing nuget restore. They are still under Dependencies but at least the exclamation marks are gone.

I've also managed to remove the analyzers by adding the <ExcludeAssets>analyzers</ExcludeAssets> directive to each AspNetCore package:

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3">
  <ExcludeAssets>analyzers</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" >
  <ExcludeAssets>analyzers</ExcludeAssets>
</PackageReference>

Now they're finally gone.

查看更多
做自己的国王
3楼-- · 2019-07-22 09:53

Search Gcop in nuget package manager removes the installed packages prefixed with GCop. this will remove the code analyzer references from your project

查看更多
登录 后发表回答