We are facing issues while analyzing .NET projects using SonarQube 5.1.1.
Please note that FxCop rules are enabled at Quality profile level.
We are using MSBuild SonarQube Runner to analyze the projects. But we are facing error which says sonar.cs.fxcop.assembly must be set.
We have faced similar issue with sonar-runner-2.4 but at that time this parameter can be passed with sonar-project.properties file.
But as sonar-runner does not support .NET projects, we are using MSBuild SonarQube Runner now.
Could you kindly confirm how we can avoid these issues with MSBuild SonarQube Runner and execute FxCop rules on the .NET projects?
C# plugin version is 4.1.
Please let me know if any further information is needed from our end.
We have postponed our Production Sonar upgrade due to this issue as Project teams are NOT OK with disabling FxCop rules at Quality Profile level.
Kindly help us in fixing this.
Thanks,
Sri Priyanka
I thinks you should read http://www.sonarqube.org/easy-analysis-of-visual-studio-solutions-with-the-sonarqube-scanner-for-msbuild/ and http://docs.sonarqube.org/display/PLUG/C%23+Plugin .
Pay attention to the fact that you should run the commands from a "Developer Command Prompt for Visual Studio 2013 or higher" (http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild). Neither DOS Command Prompt nor Windows PowerShell work because they don't set the proper variables.
The FxCop native support doesn't mean that it comes with MSBuild SonarQube Runner, but you have to install Visual Studio >= 2013.
Moreover, I found that not only sonar-project.properties has been deprecated, but you have to remove it to avoid strange behaviors.
Related
We started to use VS2019 and all the new things that comes with. We noticed that the build manager doesn't work anymore:
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 and 15.0 are supported
3. The begin, build and end steps have not all been launched from the same folder
4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
I checked, but I thing I've the latest version of SonarScanner installed. I'm kind of stuck, how to execute all our tests if we use some things of the MSBUILD V16(2019) compiler, but sonar cube doesn't seems to be compatible?
Is there a workaround?
Thanks
According to this site the sonarlint or sonar scanner should be version 2 if you are using the C# plugin 4.5 or higher (i am using v5)
But when I look at the files included the sonarlint version is v1.10.
Is this correct or is the incorrect version currently bundled with the C# plugin.
My problem is that After I installed VS2015 SP2 on the build server SonarQube stopped logging Issues, and with my debugging this is one of the last items on the list of possible causes.
If I change Build Definition to use MSBuild 12 the issues are logged but not on MSBuild 14. And no issues are logged when I execute the process from Command Prompt using MSBuild 12 or 14. From what I can see all the result files and everything still works they are just not imported into sonarqube.
edit: Relates to this Question basically I am trying to find the actual problem and solution
The doc you point at does not mention SonarLint at all. The v2 (in the compatibility matrix) refers to the version the SonarQube Scanner for MSBuild so with Scanner for MSBuild v2 and C# Plugin v5 you're all good. SonarLint is a different thing altogether, you shouldn't care about some of its libraries being embedded in the C# plugin.
After following several blogs detailing how to get xUnit working with Team Services Build vNext:
http://tech.trailmax.info/2014/01/run-xunit-in-hosted-team-foundation-service/
Running unit tests in TFS/VSO Build vNext using xUnit adapter
http://www.donovanbrown.com/post/2015/06/15/how-to-run-xunit-test-with-vnext-build
None of which worked for me. From examining the build logs I get the following warnings for each of my test assemblies.
--------------------
Warning: [xUnit.net 00:00:00.1644156] Exception discovering tests from CHO.SAM.Business.Test: System.BadImageFormatException:
Could not load file or assembly 'c:\_Work\473cef3c\CHO\CHO.ALL\Tests\CHO.SAM.Business.Test\CHO.SAM.Business.Test\bin\Debug\xunit.execution.desktop.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
--------------------
Has anyone seen this before? and if so did you figure out a solution?
My thoughts are; my test projects are compiled using .NET Framework 4.6, I was wondering if this could be causing the problem? If so I would have to move over to nUnit or something as I don't feel it's right to change the compilation just to use a single test framework.
Add "/Framework:Framework45" to "Advanced/Other console options" (to run under .NET 4.5)
or
Add "/Framework:Framework40" to "Advanced/Other console options" (to run under .NET 4.0)
or
Change "Advanced/VSTest version" to "Visual Studio 2013" (to run under .NET 3.5)
This error is normally caused by a x64 compiled assembly running on x86 test runner or vice versa. Check the solution build configuration that is being run.
I had this same issue. Adding a UI test did not fix it for me. I found two alternatives that work:
use .net 4.5
OR
Set the advanced options of the VSTest task to use 2013 instead of 2015.
Hopefully this will be fixed soon.
In the end, I added a Visual Studio Coded UI test project and removed all it's contents (a class), it's empty!
I'm assuming it's added a reference or something that the build server felt it needed.
I am now getting my unit tests discovered, running and with code coverage.
Wierd!
It works, but I don't know why...
I ran into this issue when using a .Net Core class library to run my xUnit tests against a .Net Core Web Project (.Net Framework). What solved the issue for me was to change the default processor for running test to X64 in VS2015 via:
Menu Bar -> Test -> Test Settings -> Default Processor Architecture -> X64
This solution was posted by #RehanSaeed here https://github.com/dotnet/cli/issues/3103
I am currently working with Microsoft Visual Studio 2012 and the new Fakes framework. And after adding my unit tests to the MSBuild and continuous integration process, the Fakes unit tests happen to raise a ShimNotSupportedException.
I tried different stuff and read into that issue and found out that, this only happens when I run my tests from the Resharper feature, or directly in the code with MSTest. These exceptions DO NOT occur when running from the Test menu bar, which made me think about checking the setting files of this features.
After further research I found some articles where it says that it might has something to do with the code coverage setting specified in the Resharper or MSTest settings and if you switch that off, it solves the issue. ShimNotSupportedException in MS VisualStudio 2012 also relates to that problem.
I also found some input on the MSDN about that issue, which confirmed me that it has to do something with the code coverage: http://social.msdn.microsoft.com/Forums/en-US/vstest/thread/17fcfdc6-1cda-4692-a242-656b48195327/ and http://social.msdn.microsoft.com/Forums/en-US/vstest/thread/bfa792b0-b3fc-4a51-b49d-f7aaf1f2f4b8.
Nevertheless, since I have to implement code coverage into the continuous integration process somehow soon, and skipping that part is not an option, I am now asking here for any advice regarding this issue, and if there is any kind of solution to that problem!
Thanks for all advice!
Fakes is not supported by MsTest: http://msdn.microsoft.com/en-us/library/ms253138.aspx.
Here's how you can run the Visual Studio Testrunner from Team City (which supports Fakes): http://blog.degree.no/2012/09/unit-testing-visual-studio-2012-fakes-in-team-city/
You can also use the Visual Studio Testrunner if you use TFS.
I am trying to convert a build system setup with TeamCity and Nant scripts to use TFS2010 (We bought the license and might just as well make use of it) After some work I get the web project to build and deploy to the web-server. We have a domain, API, test and web project in our solution.
How do I configure TFS to run the unit tests that we have written so far? I did configure the build to look for ***.UnitTest.dll in(VS2010) Edit build definition>Process>Automated Tests
Now the build fails with a message that says:"Could not load file or assembly 'nunit.framework, Version=2.5.3.9345" Am I correct when I say that TFS is trying to run NUnit on the build server? I did install NUnit-2.5.3.9345 on that TFS2010 build server and still nothing?
Thank you
Jack
The build facility in TFS uses MSTest as test runner, with which it's tightly integrated.
If you want to run your unit tests with NUnit as part of your build, take a look at the NUnit for Team Build project on CodePlex.
The project started out for TFS 2008, however support for TFS 2010 has been added in version 2.0. Note that this feature is still in early stages of development, so your mileage may vary.
I'm late to the game, because I've had to deal with this issue recently. I found this article helpful for me in this. It didn't work right off the bat, but I found if I added it into my buildscript via the controls in a similar manner/pattern, it would work.
My only problem now has been getting it to actually error (right now it warns) even when flagging them to cause the build to error
Link: http://blog.gfader.com/2011/06/running-nunit-tests-in-tfs-2010.html