Failed to locate the code coverage command line tool , MSBuild with SonarQube - sonarqube-msbuild-runner

Getting the following error's once build is triggered from the build definition.
3:46:16 AM Failed to locate the code coverage command line tool Post-processing failed. Exit code: 1
Exception Message: TF270015: 'MSBuild.SonarQube.Runner.exe' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details. (type UnexpectedExitCodeException)
Exception Stack Trace:
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I am using SonarQube 5.3, installed in the build server. I have .net framework installed in build server not the visual studio .
BuildDefinition where I am referencing SonarQube.
Please help me here !!!!

The code coverage tools are installed with Visual Studio not the .Net Framework, so if you want code coverage you'll need to install VS on the build agent.
Depending on the version of Visual Studio you are using, you may not need an additional license for build agent. See the discussion Is a separate Visual Studio license required for a build machine? get more detail.

Related

Using XAML UpgradeTemplate with TFS 2015 \ 2017

I ran into this issue upgrading from TFS 2013 to 2017. If you are still using the UpgradeTemplate.xaml to run old TFS 2005\2008 style MSBuild Team Builds (TFSBuild.proj) you will find that they do not work with the TFS 2015 or 2017 XAML build agent.
You will get this error when running the build due to some breaking changes that were introduced in the core assemblies. XAML builds have been deprecated for some time... and the old MSBuild based Team Builds are waaaayyyyy out of support. So Microsoft (rightfully) doesn't care.
But is there a way to get these builds working in TFS 2015\2017? It would be a big waste of time to convert these over to using XAML builds only to then convert them to the new build engine after upgrading to TFS 2017.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (957): The following errors were encountered while processing the workflow tree:
'VisualBasicValue<LabelChildOption>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.LabelChildOption.Fail".
'LabelChildOption' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.
'VisualBasicValue<RecursionType>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.RecursionType.Full".
'RecursionType' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (957): The "Label" task failed unexpectedly.
System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
'VisualBasicValue<LabelChildOption>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.LabelChildOption.Fail".
'LabelChildOption' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.
'VisualBasicValue<RecursionType>': Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.VersionControl.Client.RecursionType.Full".
'RecursionType' is ambiguous in the namespace 'Microsoft.TeamFoundation.VersionControl.Client'.
at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
at System.Activities.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager extensionManager)
at System.Activities.WorkflowApplication.EnsureInitialized()
at System.Activities.WorkflowApplication.RunInstance(WorkflowApplication instance)
at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary`2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout)
at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary`2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions)
at Microsoft.TeamFoundation.Build.Tasks.WorkflowTask.ExecuteInternal()
at Microsoft.TeamFoundation.Build.Tasks.Task.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
You can work around this error if you don’t care about labeling your code as part of the build process or updating associated work items. In my case I was still using the UpgradeTemplate as a convenient way of performing a check-in based “Get-Latest” of source code in TFVC to the builds folder on the build machine… not really a “build” at all. So this was A-OK.
Set these two properties to true in your TFSBuild.proj
This will cause MSBuild to skip execution of the CoreLabel and the CoreGetChangesetsAndUpdateWorkItems targets. CoreLabel is the one which loads the task that is failing the build... and CoreGetChangesetsAndUpdateWorkItems needs the label to exist or it will also fail.
I found these properties by digging through the old C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets - which is the team build script that shipped with TFS 2005 \ 2008.
<SkipLabel>true</SkipLabel>
<SkipGetChangesetsAndUpdateWorkItems>true</SkipGetChangesetsAndUpdateWorkItems>

SonarQube MSBuild Runner and TFS 2013 in VisualStudio Remote server returns unauthorized

I have edited a build definition from TFS 2013 inside of Visual Studio following the steps from Setup of the MSBuild SonarQube Runner on the Build Agent Machine and Install the SonarQube Scanner for MSBuild. I am getting the exact same errors as the question from this post as well as one that reads:
Exception Message: TF270015: 'MSBuild.SonarQube.Runner.exe' returned an unexpected exit code. Expected '0'; actual '255'. See the build logs for more details. (type UnexpectedExitCodeException)
Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I've updated the SonarQube.Analysis.xml file with the correct information and followed the steps of the aforementioned post, updating the Global Permissions for Execute Analysis inside of SonarQube. I have tried updating IIS AppPool info for the service I am trying to build as well as updating Network Service access permissions, but to no avail. Anyone's advice is greatly appreciated!

Visual Studio Team Services sends "build failed" email when build succeeds

We're using Visual Studio Team Services for a project, and because we want to use continuous integration I set it up to build on each check-in, and to notify me when a build fails. Now, every time someone checks in code, I get an email that tells me the build failed:
Summary
Debug | Any CPU
3 error(s), 0 warning(s)
$/Foo/Bar.Foo/Bar.Foo.sln - 3 error(s), 0
warning(s)
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets
(126): The Dnx Runtime package needs to be installed. See output
window for more details.
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets
(126): The Dnx Runtime package needs to be installed. See output
window for more details.
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DNX\Microsoft.DNX.targets
(126): The Dnx Runtime package needs to be installed. See output
window for more details.
Other Errors
1 error(s)
Exception Message:
MSBuild error 1 has ended this build. You can find more specific
information about the cause of this error in above messages. (type
BuildProcessTerminateException) Exception Stack Trace: at
System.Activities.Statements.Throw.Execute(CodeActivityContext
context) at
System.Activities.CodeActivity.InternalExecute(ActivityInstance
instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at
System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
When I go to visualstudio.com to check out the completed builds, the build in question is listed as "Succeeded". When I check the logs, everything is fine, and when I get a latest version and build locally, it also builds.
If I go to the "alerts" tab on the administration panel, I have one alert specified, with the following filters:
Team Project = [Current project]
AND Status = Failed
What's going on here?
I cannot say if it is safe to delete it since you don't know where it came from. And if you want to edit a XAML build definition, you need to do it from "Visual Studio\Team Explorer\Builds\XAML Build Definitions":
However, before you figure out if the XAML definition can be deleted, you can add one more filter in alert to set the alert to only track the build definition you want:

VSTS Build fails running NUnit tests

When building a visual studio solution using visual studio team services it runs the unit tests, written in nunit 3 using the nunit 3 NUnit3TestAdapter it starts running the tests.
The error it gives is: Error: Illegal characters in path.
The complete output as follows
2016-02-11T17:02:40.8514411Z Executing the powershell script: C:\BuildAgent\tasks\VSTest\1.0.29\VSTest.ps1
2016-02-11T17:02:41.1483135Z ##[debug]Calling Invoke-VSTest for all test assemblies
2016-02-11T17:02:41.2108131Z Working folder: C:\BuildAgent\_work\5
2016-02-11T17:02:41.2108131Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\BuildAgent\_work\5\s\xxxxxxxxxxTests\bin\Release\xxxxxxxxxxTests.dll" /logger:trx /TestAdapterPath:"C:\BuildAgent\_work\5\s"
2016-02-11T17:02:41.5240692Z Microsoft (R) Test Execution Command Line Tool Version 14.0.24720.0
2016-02-11T17:02:41.5240692Z Copyright (c) Microsoft Corporation. All rights reserved.
2016-02-11T17:02:42.1326930Z Starting test execution, please wait...
2016-02-11T17:02:46.4921857Z Information: NUnit Adapter 3.0.8.0 executing tests is started
2016-02-11T17:02:46.5077303Z Information: Running all tests in C:\BuildAgent\_work\5\s\xxxxxxxxxxTests\bin\Release\xxxxxxxxxxTests.dll
2016-02-11T17:02:46.6327336Z Information: NUnit Adapter 3.0.8.0 executing tests is finished
2016-02-11T17:02:46.6327336Z ##[error]Error: Exception System.ArgumentException, Exception thrown executing tests
2016-02-11T17:02:46.6327336Z ##[error]
2016-02-11T17:02:46.6327336Z ##[error]Error: Illegal characters in path.
2016-02-11T17:02:46.6327336Z ##[error]
2016-02-11T17:02:46.7108474Z Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions. Example: vstest.console.exe myTests.dll /UseVsixExtensions:true
2016-02-11T17:02:46.8358887Z ##[error]VSTest Test Run failed with exit code: 1
2016-02-11T17:02:46.8514965Z ##[warning]No results found to publish.
We have an on premise build agent but I don't think this should make an difference.
Any advice you can give it appreciated.
FWIW, I switched on verbose logging by following the Tips and Tricks and got this:
2016-02-23T14:45:49.5620657Z Information: Running all tests in C:\TFS2015\_work\3\s\BlaBlaTests\bin\Debug\BlaBlaTests.dll
2016-02-23T14:45:49.6088663Z ##[error]Error: Exception thrown executing tests
2016-02-23T14:45:49.6088663Z ##[error]
2016-02-23T14:45:49.6088663Z ##[error]Error: System.ArgumentException: Illegal characters in path.
2016-02-23T14:45:49.6088663Z ##[error] at System.IO.Path.CheckInvalidPathChars(String path)
2016-02-23T14:45:49.6088663Z ##[error] at System.IO.Path.Combine(String path1, String path2)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.Services.ExtensionService.ProcessAddinsFile(DirectoryInfo baseDir, String fileName)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.Services.ExtensionService.FindExtensionsInDirectory(DirectoryInfo startDir)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.Services.ExtensionService.StartService()
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.Services.ServiceManager.StartServices()
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.TestEngine.Initialize()
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.VisualStudio.TestAdapter.NUnitTestAdapter.GetRunnerFor(String assemblyName)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyName, IFrameworkHandle frameworkHandle)
2016-02-23T14:45:49.6088663Z ##[error] at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
2016-02-23T14:45:49.6088663Z ##[error]
2016-02-23T14:45:49.6088663Z Information: NUnit Adapter 3.0.8.0 executing tests is finished
which correlates with %LOCALAPPDATA%\NUnit\Nunit30Settings.xml being accessed but might not be related. ExtensionService is here.
Issues #117 and #118 are related to this with a fix as provided by RobertK66:
If you install the Version 3.0.8.0 as a Nuget package then there is a
corrupted (not empty!) “ignore.addins” file installed in the
packages\NUnit3TestAdapter.3.0.8-ctp-8\lib folder. Earlier Versions
did install a 0byte empty file!
After removing the content of this file in the
/packages/NUnit3TestAdapter.3.0.8-ctp-8\lib folder and
deleting the cached version of the adapter under
\AppData\Local\Temp\VisualStudioTestExplorerExtensions...
everything works as expected!
I met this issue when I use NUnit3 Test Adapter Nuget Package during the build. And I resolved it by installing NUnit3 Test Adapter and upload all the installed files to Version Control and use it as the Test Adapter.
Since you are using on premise build agent. You can easily install the NUnit3 Test Adapter on the build agent and use "/UseVsixExtensions:true" argument as the error message indicates.

Visual Studio Online test runner can't load SpecFlow dll

I've added SpecFlow using Nuget and have a single spec (so it is a simple project). I've created a build in VS online 2015 using the web build editor.
Maybe it's a Nuget new build system issue? I'm not sure if it just a SpecFlow thing and haven't gotten a chance try straight MS unit tests yet.
An exception occurred while invoking executor
'executor://mstestadapter/v1': Could not load file or assembly
'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral,
PublicKeyToken=0778194805d6db41' or one of its dependencies. The
system cannot find the file specified.
Here's a larger stack trace:
1. 2015-08-03T21:26:27.6325511Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\VSTest\1.0.16\VSTest.ps1
2. 2015-08-03T21:26:28.4231183Z ##[debug]Calling Invoke-VSTest for all test assemblies
3. 2015-08-03T21:26:28.4481177Z Working folder: C:\a\14076a40
4. 2015-08-03T21:26:28.4481177Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\a\14076a40\SpecByExample\SpecByExample.Specs\bin\Debug\SpecByExample.Specs.dll" "C:\a\14076a40\SpecByExample\SpecByExample.Specs\bin\Debug\SpecByExample.Specs.dll.config" "C:\a\14076a40\SpecByExample\SpecByExample.Specs\obj\Debug\SpecByExample.Specs.dll" /logger:trx
5. 2015-08-03T21:26:29.4654019Z Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
6. 2015-08-03T21:26:29.4664025Z Copyright (c) Microsoft Corporation. All rights reserved.
7. 2015-08-03T21:26:29.4664025Z Starting test execution, please wait...
8. 2015-08-03T21:26:29.7564024Z Warning: Unable to load types from the test source 'C:\a\14076a40\SpecByExample\SpecByExample.Specs\obj\Debug\SpecByExample.Specs.dll'. Some or all of the tests in this source may not be discovered. If you are running unit tests for Windows Store apps and referencing custom WinMD type then please visit http://go.microsoft.com/fwlink/?LinkId=238340 for more info. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'SpecResults, Version=0.1.0.7, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
9. 2015-08-03T21:26:29.7574029Z .
10. 2015-08-03T21:26:40.6922424Z Passed TheUserVisitsTheWebsite
11. 2015-08-03T21:26:41.3214684Z ##[error]Error: An exception occurred while invoking executor 'executor://mstestadapter/v1': Could not load file or assembly 'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral, PublicKeyToken=0778194805d6db41' or one of its dependencies. The system cannot find the file specified.
12. 2015-08-03T21:26:41.3224680Z ##[error]
13. 2015-08-03T21:26:41.4936886Z Results File: C:\a\14076a40\TestResults\buildguest_TASKAGENT-0007 2015-08-03 21_26_40.trx
14. 2015-08-03T21:26:41.4956876Z Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
15. 2015-08-03T21:26:41.4966881Z ##[error]Test Run Failed.
16. 2015-08-03T21:26:41.4966881Z Test execution time: 11.8787 Seconds
17. 2015-08-03T21:26:41.7581094Z ##[error]VSTest Test Run failed with exit code: 1
18. 2015-08-03T21:26:41.7741099Z Publishing Test Results...
2015-08-03T21:26:43.0372165Z Test results remaining: 1
UPDATE: I disabled the SpecFlow test and added the simplest AboutController test possible (from file new project MVC in Visual Studio). I still get a 'could not load assembly problem. SpecByExample.Web is my MVC project in my solution.
2015-08-07T16:16:56.7251975Z ##[error]Error Message:
2015-08-07T16:16:56.7261978Z ##[error] Test method
SpecByExample.Web.Tests.Controllers.HomeControllerTests.AboutTest
threw exception: 2015-08-07T16:16:56.7261978Z
[error]System.IO.FileNotFoundException: Could not load file or assembly 'SpecByExample.Web, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified.WRN: Assembly binding logging is turned OFF.
2015-08-07T16:16:56.7271982Z ##[error]To enable assembly bind failure
logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2015-08-07T16:16:56.7271982Z ##[error]Note: There is some performance
penalty associated with assembly bind failure logging.
2015-08-07T16:16:56.7281979Z ##[error]To turn this feature off, remove
the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
2015-08-07T16:16:56.7281979Z ##[error] 2015-08-07T16:16:56.7291971Z
[error]Stack Trace: 2015-08-07T16:16:56.7291971Z ##[error] at SpecByExample.Web.Tests.Controllers.HomeControllerTests.AboutTest()
2015-08-07T16:16:56.7831986Z Results File:
C:\a\14076a40\TestResults\buildguest_TASKAGENT-0007 2015-08-07
16_16_56.trx 2015-08-07T16:16:56.7861977Z Attachments:
2015-08-07T16:16:56.7861977Z ##[error]Test Run Failed.
Here's a screenshot of my build definition:
In Run unit test step. click advance and give path to your packages folder. (if you are using nuget it will download all dependencies there) give it a try and let me know how it goes.