Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSharp sensor should fail if OS is not windows. #535

Closed
jannylund opened this issue Jul 5, 2017 · 16 comments
Closed

CSharp sensor should fail if OS is not windows. #535

jannylund opened this issue Jul 5, 2017 · 16 comments
Assignees
Labels
Area: SQ Plugin Java plugin related issues. Type: Bug Exceptions and blocking issues during analysis.
Milestone

Comments

@jannylund
Copy link

Description

If a build server accidentally pushes a csharp analysis to a non-windows system, the c# files are ignored in analysis (without warning) and sonar history deletes them. It's not possible to delete the latest analysis in Sonar, so this is breaking the history until rescan on Windows has happened.

When running in debug mode, there is a warning about OS Incompatibility.

Repro steps

  1. Scan C# project on Mac or Linux.

Expected behavior

Sonar C# should either:

  • scan C# as good as possible
  • fail and stop the analysis.

Actual behavior

  • Silently goes forward while only logging in debug mode.
  • Resets C# analysis on SonarQube server

Known workarounds

  • Dont' run on non-windows.
@jannylund jannylund changed the title CSharp sensor shold fail if OS is not windows. CSharp sensor should fail if OS is not windows. Jul 6, 2017
@FastNinja
Copy link

FastNinja commented Aug 9, 2017

Expected behavior
Sonar C# should:
scan C# as good as possible

@fmallet
Copy link
Contributor

fmallet commented Aug 9, 2017

@jannylund, how do you manage to run a .Net analysis on a non-windows OS as the only way to execute a .Net analysis is thru the Scanner for MSBuild which can't be executed on non-windows machine ? Thanks

@jannylund
Copy link
Author

@fmallet previously sonar supported doing source-code-only analysis by using the sonar-runner/sonar-scanner command line tool. This was an easy way to get a quick overview of a legacy project before setting up the full build environment to run with sonar scanner.

Today, running somar-scanner on linux will still pull the C# rules from the server and then as mentioned in the ticket, kill the analysis history. If you don't support non-windows, please make it throw an ERROR and quit analysis.

@Evangelink Evangelink added Area: Scanner Msbuild Area: SQ Plugin Java plugin related issues. Type: Bug Exceptions and blocking issues during analysis. labels Aug 14, 2017
@lextm
Copy link

lextm commented Sep 27, 2017

@fmallet Just curious. JetBrains ported their ReSharper analysis engine to Mono and then became the core part of Rider IDE. MSBuild has been open sourced by Microsoft and is now able to run on non-Windows machines. So all the information seems to indicate the feasibility of running a scanner everywhere.

@liortal53
Copy link

@lextm analysis IS possible on non-windows (e.g: MacOS). see this "beta" build that provides this basic support: https://github.com/SonarSource/sonar-scanner-msbuild/releases/tag/3.1-beta.1

I am currently trying to scan on my mac but it fails due to the "fix" done by this issue. If analysis can be performed on a mac, i believe the code changes for this commit should be reverted (or, at least, provide a matching "beta" release for the SonarC# plugin, from a different branch perhaps).

@Evangelink
Copy link
Contributor

@liortal53 We decided to implement this "feature" to avoid weird and unexpected behaviors. We will obviously remove this as soon as we think we are ready with cross-platform support.

@liortal53
Copy link

I understand that. but currently, it appears that even without full .net core support, it may be possible to analyze C# projects from a Mac. It was also suggested by someone on the open JIRA ticket (can't find the link now).

i'd like to have this support, even as an "experimental", "beta" or whatever other title it is you want to call that. alternatively, i can just comment out the code you added that tests for Windows OS, but i was unable to rebuild the plugin so i can't replace my version with a locally built version for testing purposes.

@michalb-sonar
Copy link
Contributor

@jannylund @FastNinja @lextm @liortal53
Good news!
Early next week, we're going to release RC of the Scanner, SonarC# and SonarVB plugins that support scanning .NET Core project, not only on Windows but also on Linux and Mac.

Watch our for the release announcement. All feedback will be very appreciated and would help us to deliver the product to a highest quality.

@michalb-sonar
Copy link
Contributor

Fixed by #944

@liortal53
Copy link

liortal53 commented Nov 17, 2017 via email

@michalb-sonar
Copy link
Contributor

@liortal53
Yes! You can analyze the .NET framework solutions with Mono.

We haven't tested unity3d specifically, so feedback here would be good.

@liortal53
Copy link

liortal53 commented Nov 17, 2017 via email

@michalb-sonar
Copy link
Contributor

Thanks! Yes, github issues would be the most convenient place.

@Evangelink
Copy link
Contributor

Evangelink commented Nov 17, 2017

But please open new issues (easier for us to handle) :)

@DR9885
Copy link

DR9885 commented Nov 30, 2018

Running into a similar issue...
OS: Ubuntu 18.04
Host: Appveyor
dotnet-sonarscanner: 4.4.2
dotnet-sdk: 2.1.500
java-jdk: 8

Any suggestions to fix this? script listed below image
(note: if i run the same code from my windows machine, it works fine)
(also note: code coverage works, but thats from my coverlet)

image

dotnet tool install --global dotnet-sonarscanner

dotnet test --filter "Category=Unit|Category=Integration" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover


dotnet build-server shutdown
dotnet sonarscanner begin /k:$PROJECT /v:$VERSION /d:sonar.host.url=$SONAR_HOST /d:sonar.login=$SONAR_USER /d:sonar.password=$SONAR_PASS /d:sonar.cs.opencover.reportsPaths="test/*/coverage.opencover.xml" 

dotnet build

dotnet sonarscanner end /d:sonar.login=admin /d:sonar.password=admin

@valhristov
Copy link
Contributor

valhristov commented Nov 30, 2018

Disregard, this is already taken care of in another thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: SQ Plugin Java plugin related issues. Type: Bug Exceptions and blocking issues during analysis.
Projects
None yet
Development

No branches or pull requests

9 participants