DanielHWe / sonar-fxcop

FxCop plugin for C# or VB.NET projects
13 stars 6 forks source link

Support for .NET Core projects #18

Open sorgeas opened 6 years ago

sorgeas commented 6 years ago

Hello,

Could you please add support for .NET Core 2.x projects? The current result (with version 1.3) is the following:

WARNING: WARN: No output type found for 'D:\a\3\s\xxx\xxx.csproj'.
WARNING: WARN: Ignore 'D:\a\3\s\xxx\xxx.csproj' due to parsing error.
WARNING: WARN: No output name found for 'D:\a\3\s\xxx\xxx.csproj'.
WARNING: WARN: Ignore 'D:\a\3\s\xxx\xxx.csproj' due to parsing error.
ERROR: No projects found to scan, can not generate FxCop configuration.

I guess that's because .NET Core 2.x csproj do not necessarily contain the tags <OutputType>, <AssemblyName> or <OutputPath>.

Thanks for your nice work, Sébastien

DanielHWe commented 6 years ago

Please check with 1.4 Beta

sorgeas commented 6 years ago

I don't see the jar file in the 1.4 Beta release, could you please add it?

DanielHWe commented 6 years ago

Done

sorgeas commented 6 years ago

Didn't have much time to test, but I ended up with an issue during my "Run code analysis" step:

IdentityServerDemoClient.exe was not found in any output directory (D:\a\3\s\IdentityServerDemoClient\bin\Debug\netcoreapp2.0, D:\a\3\s\IdentityServerDemoClient\bin\Release\netcoreapp2.0), please build project before scan.

This project is supposed to produce a DLL, but the fxcop plugin seems to expect an EXE file? Here is the output of my build step:

IdentityServerDemoClient -> D:\a\3\s\IdentityServerDemoClient\bin\Debug\netcoreapp2.0\IdentityServerDemoClient.dll

DanielHWe commented 6 years ago

Is there a Output type defined in the csproj file? Because I made Libryry (dll) the Default.

sorgeas commented 6 years ago

Hi Daniel,

I've tested with another solution, and now I end up with the following output:

INFO: Could not identify platform for "myproject.dll".
FxCopCmd.exe ended with the exit code: 1

Here is the content of the related csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

</Project>
DanielHWe commented 6 years ago

I get the same error in case I use FxCopCmd.exe and scan a .net core exe. Are you sure that FxCop supports .net core? If yes do you know the requirements and required options?

DanielHWe commented 6 years ago

I think this has to be done in a diffrent way see: