C# project in sonarqube - c#

When I run sonar-runner for an analysis my simple C# project the analysis terminate on error on SonarLint.Runner.exe of permission denied:
ERROR: Error during SonarQube Scanner execution
ERROR: java.io.IOException: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: error=13, Permission denied
Effectively
-rw-r--r-- 1 root root 19456 Apr 5 11:14 .sonar/Lint.Runner/SonarLint.Runner.exe
This following is my sonar-project.properties:
# Root project information
sonar.projectKey=ArturiCSharpSort
sonar.projectName=ArturiCSharpSort
sonar.projectVersion=1.0
# Some properties that will be inherited by the modules
sonar.sources=.
#List of the module identifiers
#sonar.modules=
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
#module1.sonar.projectName=
#module2.sonar.projectName=
I try to act a chmod on SonarLint.Runner.exe but it is rebuil at every analysis.
How can I run analysis on C# project?

Analysis of C# projects must be done on a Windows environment. Here it's failing because the project is analysed on Linux.
The thing is that SonarQube C# Plugin really is targeted to the Windows .NET ecosystem, which is where you'd anyhow build/maintain .NET projects. It must be used with the SonarQube Scanner for MSBuild, which requires MSBuild 14.0.

Related

Coverity scan for .Netstandard 2.1 library

I am trying to use Coverity with my .NetStandard2.1 library.
using commands like:
set COVERITY_PATH="C:\Users\xxx\Desktop\cov-analysis-win64-8.5.0\bin"
set PATH=%PATH%;%COVERITY_PATH%
cov-configure --cs
cov-build --dir MY_EMIT_DIR dotnet build || (echo build failed )
echo "build successfully!!"
cov-analyze --dir MY_EMIT_DIR
cov-commit-defects --dir MY_EMIT_DIR --host 10.ccc.aaa.bbb --user xxxxx --password xxxxx --stream CSProject
After running the command getting the warning and error:
[WARNING] No files were emitted. This may be due to a problem with
your configuration or because no files were actually compiled by your
build command. Please make sure you have configured the compilers
actually used in the compilation. For more details, please look at:
C:/xxx/Src/MY_EMIT_DIR/build-log.txt
C:\xxx\Src>cov-analyze --dir MY_EMIT_DIR
Coverity Static Analysis version 8.5.0 on Windows 10 (Unknown Edition number 121), 64-bit (build 19042)
Internal version numbers: c8d197a567 p-kent-push-26368.915
Using 1 worker as limited by CPU(s)
Looking for translation units
Error: intermediate directory contains no translation units.
I also tried to set the compiler explicitly like,
cov-configure --compiler "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\csc.exe"

Error : Unable to load DLL 'libgmp-10.dll' when testing azure function c# .net 5.0

I published my c# .NET 5.0 code to azure functions (windows) and im getting this weird error message:
2021-06-21T01:56:53.465 [Error] Executed 'Function1' (Failed, Id=fdefdbba-49a7-44ad-8082-841d2941d90b, Duration=169ms)Unable to load DLL 'libgmp-10.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I tried to see the \wwwroot files on the azure functions console but then i get this error:
3 [main] ls (8392) C:\Program Files\Git\usr\bin\ls.exe: *** fatal error - Couldn't set directory to \\?\PIPE\ temporarily.
Any hints?
It seems that the deployment is not done correctly.
Libgmp-10.dll a DLL (Dynamic Link Library) file which is referred to
essential system files of the Windows OS. It usually contains a set of
procedures and driver functions, which may be applied by Windows.
Please delete the Azure Function and, re-create and deploy a fresh code using Develop and publish .NET 5 functions using Azure Functions OR if you are using ADO, Setting up a CI/CD pipeline for Azure Functions.
Let me know if you have any follow up questions.

My hosted Azure pipeline is failing with: rcz discover exited with code -2147450730

I have two aspnet core 3.1 applications and have set up two azure piplines:
One pipeline is working fine building and testing my project, the other one (similar structure and referencing same projects) is failing with following error:
C:\hostedtoolcache\windows\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets(404,5): warning RAZORSDK1006: Detected Razor language version downgrade. This is typically caused by a reference to the Microsoft.AspNetCore.Razor.Design package. Consider removing this package reference. [d:\a\1\s\Sources\Web\Web.csproj]
CSC : warning CS8034: Unable to load Analyzer assembly C:\Users\VssAdministrator\.nuget\packages\microsoft.aspnetcore.mvc.analyzers\2.2.0\analyzers\dotnet\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll : Assembly with same name is already loaded [d:\a\1\s\Sources\Web\Web.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79,5): error : rzc discover exited with code -2147450730. [d:\a\1\s\Sources\Web\Web.csproj]
54 Warning(s)
1 Error(s)
Time Elapsed 00:02:41.66
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\Sources\Web\Web.csproj
Does someone have an idea what I can check?
Kind regards

Getting error while running SonarScannerMSBuild on Xamarin projects

1) When I Try to use Rebuild option
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/MSBuild.SonarQube.Runner.exe /t:Rebuild
WARNING: ------------------------------------------------------------------------
This executable is deprecated and may be removed in next major version of the SonarScanner for MSBuild. Please use 'SonarScanner.MSBuild.exe' instead.
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Pre-processing started.
Preparing working directories...
05:23:39.463 05:23:39.454 Unrecognized command line argument: /t:Rebuild
05:23:39.464 05:23:39.462 A required argument is missing: /key:[SonarQube project key]
05:23:39.464 Expecting at least the following command line argument:
SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
SonarQube project name
SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
05:23:39.464 Pre-processing failed. Exit code: 1
2) I get some other error with authentication problems. Any work around this.
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarScanner.MSBuild.exe begin /k:"Xamarin" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token1"
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
05:18:52.798 Updating build integration targets...
05:18:52.833 Fetching analysis configuration settings...
05:18:52.94 Failed to request and parse 'http://localhost:9000/api/settings/values?component=Xamarin': The remote server returned an error: (401) .
05:18:52.94 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
05:18:52.941 Pre-processing failed. Exit code: 1

Sonar Scanner for MSBuild on linux [duplicate]

When I run sonar-runner for an analysis my simple C# project the analysis terminate on error on SonarLint.Runner.exe of permission denied:
ERROR: Error during SonarQube Scanner execution
ERROR: java.io.IOException: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: error=13, Permission denied
Effectively
-rw-r--r-- 1 root root 19456 Apr 5 11:14 .sonar/Lint.Runner/SonarLint.Runner.exe
This following is my sonar-project.properties:
# Root project information
sonar.projectKey=ArturiCSharpSort
sonar.projectName=ArturiCSharpSort
sonar.projectVersion=1.0
# Some properties that will be inherited by the modules
sonar.sources=.
#List of the module identifiers
#sonar.modules=
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
#module1.sonar.projectName=
#module2.sonar.projectName=
I try to act a chmod on SonarLint.Runner.exe but it is rebuil at every analysis.
How can I run analysis on C# project?
Analysis of C# projects must be done on a Windows environment. Here it's failing because the project is analysed on Linux.
The thing is that SonarQube C# Plugin really is targeted to the Windows .NET ecosystem, which is where you'd anyhow build/maintain .NET projects. It must be used with the SonarQube Scanner for MSBuild, which requires MSBuild 14.0.

Categories

Resources