SonarSource / sonar-scanner-msbuild

SonarScanner for .NET
http://redirect.sonarsource.com/doc/msbuild-sq-runner.html
GNU Lesser General Public License v3.0
356 stars 143 forks source link

Request to Create NuGet Package for SonarScanner .NET Framework Version #1944

Open marco-carvalho opened 1 month ago

marco-carvalho commented 1 month ago

The sonar-scanner-6.2.0.85879-net.zip has a NuGet package available, but the sonar-scanner-6.2.0.85879-net-framework.zip does not.

Would it be possible for SonarSource to also create a NuGet package for the .NET Framework scanner? This addition would greatly enhance the ease of integration and usage for projects targeting the .NET Framework, providing consistency and simplifying the setup process.

While there is an existing dotnet-framework-sonarscanner package, it is not an official release from SonarSource. Having an official NuGet package for both versions ensures that all .NET developers, regardless of their framework, can benefit from a streamlined and standardized toolset, aligning with modern development practices and improving the overall developer experience.

Thank you for considering this enhancement.

costin-zaharia-sonarsource commented 1 month ago

Hi @marco-carvalho,

The current version of the scanner can be used to analyze also projects targeting .NET Framework.

The only requirement is that you need to have installed a recent version of dotnet to be able to run the BEGIN and END steps.

If there is a scenario that is not supported we would need more details.

marco-carvalho commented 1 month ago

Hi @costin-zaharia-sonarsource!

The project I work was built using the ASP.NET Web Application (.NET Framework) template. When I try to install dotnet-sonarscanner in this project, I receive a message like this: Package 'dotnet-sonarscanner 6.2.0' has a package type 'Dotnet Tool' that is not supported by project 'WebApplication1'.

marco-carvalho commented 1 month ago

Link for a repo you can try: https://github.com/marco-carvalho/dotnet-framework-legacy

marco-carvalho commented 1 month ago

I thought it didn't had support for .NET Framework because in NuGet is stating the package only has support for newer versions. image

marco-carvalho commented 1 month ago

If dotnet-sonarscanner can also target netstandard2.0 or something, that would be nice.

costin-zaharia-sonarsource commented 1 month ago

Hi Marco,

There are two separate things:

The two of them should be decupled. At least in theory :).

I think you are experiencing an issue that we need to investigate and better understand where the problem is.

marco-carvalho commented 4 weeks ago

Hi @costin-zaharia-sonarsource!

I just desire to install the NuGet package dotnet-sonarscanner in this .NET Framework project dotnet-framework-legacy, but get the error Package 'dotnet-sonarscanner 6.2.0' has a package type 'Dotnet Tool' that is not supported by project 'WebApplication1'.

costin-zaharia-sonarsource commented 1 week ago

Hi @marco-carvalho

First of all, I'm sorry for the very late reply.

I did try to reproduce the problem locally without any luck.

The steps I followed:

The begin step works without any problems for the test project provided by you.

What dotnet version do you have installed?

Here is my test environment:

dotnet tool list
Package Id      Version      Commands      Manifest
---------------------------------------------------
PS D:\src\temp\dotnet-framework-legacy> dotnet tool list -g
Package Id               Version      Commands
---------------------------------------------------------
dotnet-sonarscanner      6.2.0        dotnet-sonarscanner
dotnet --info
dotnet --info
.NET SDK:
 Version:           8.0.302
 Commit:            ef14e02af8
 Workload version:  8.0.300-manifests.ca8b4b2d
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.302\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.6
  Architecture: x64
  Commit:       3b8b000a0e

.NET SDKs installed:
  8.0.302 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download