简体   繁体   中英

Code analysis for dotnet core project in VS2017

I want add code analysis (FxCop, not StyleCop) for my dotnet core project, it is targeting netcoreapp1.1 framework. I know that FxCop is built in MSBuild, but when I enabled it, I kept getting error:

1>MSBUILD : error : CA0055 : Could not identify platform for 'C:\\Dev\\easycube\\EasyCube.Authentication\\bin\\Debug\\netcoreapp1.1\\EasyCube.Authentication.dll'. 1>MSBUILD : error : CA0052 : No targets were selected.

Then I found that there is Nuget package for dotnet core analyzer Microsoft.NetCore.Analyzers, but I do not know how to use it. Anyone know how to set it up on the project?

Thank you.

.Net Core does not support Code Analysis the old way.

You need the Nuget Package Microsoft.CodeAnalysis.FxCopAnalyzers . Add it to your project and you will get the warnings. See here for some more Analyzers .

If you try to run the old code analysis on a solution with .Net Core project you can switch it off for every project (see here ) by adding a custom target to the end of the project files:

<Target Name="IgnoreRunCodeAnalysis" Condition=" '$(RunCodeAnalysis)' == 'true' " BeforeTargets="RunCodeAnalysis">
    <Message Importance="normal" Text="Set RunCodeAnalysisOnThisProject to false" />
    <PropertyGroup>
        <RunCodeAnalysisOnThisProject>false</RunCodeAnalysisOnThisProject>
    </PropertyGroup>
</Target>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM