任何人都知道VS任务,参数和命令行的正确组合,以便让这4件事情一起玩得很好吗?
我可以让SonarQube对执行以下操作的代码进行分析:
但Visual Studio Test任务找不到我编写的任何dotnetcore 2.0测试(尝试过MSTest和xUnit框架,以及一大堆参数)
我可以让dotnet构建/测试任务工作,但是我无法让SonarQube扫描仪CLI做任何事情,但会爆发以
开头的错误 2017-09-29T17:38:40.6401974Z ##[error]ERROR: Error during SonarQube Scanner execution
2017-09-29T17:38:40.6401974Z ##[error]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
2017-09-29T17:38:40.6401974Z ##[error]at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:71)
寻找有关如何获得VS-Task" Visual Studio Test"运行dotnetcore 2.0内置测试或让SonarQube CLI与VSTS托管代理一起运行...
更新:第一个答案中的说明使构建工作(感谢您提供有关如何运行.NET Core 2.0测试的提示!!我无法在任何地方找到该框架密钥... SonarQube是现在爆炸了。这是VSTS步骤的日志(有调试)
==============================================================================
Task : SonarQube Scanner for MSBuild - End Analysis (new)
Description : Complete the SonarQube analysis of your solution
Version : 3.0.2
Author : SonarSource
Help : Version: 3.0.2. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
Preparing task execution handler.
Executing the powershell script: d:\a\_tasks\SonarQubeScannerMsBuildEnd_6d01813a-9589-4b15-8491-8164aeb38055\3.0.2\SonarQubePostTest.ps1
PowerShellHandler.Execute - AddCommand(d:\a\_tasks\SonarQubeScannerMsBuildEnd_6d01813a-9589-4b15-8491-8164aeb38055\3.0.2\SonarQubePostTest.ps1)
PowerShellHandler.Execute - Invoke
Starting SonarQube PostBuild Step
Loading module from path 'C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.123.0\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.psd1'.
Loading module from path 'C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.123.0\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.psm1'.
Loading module from path 'C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.123.0\externals\vstshost\Microsoft.TeamFoundation.DistributedTask.Task.LegacySDK.dll'.
Importing cmdlet 'Invoke-ResultPublisher'.
Importing cmdlet 'Publish-TestResults'.
Importing cmdlet 'Add-BuildArtifactLink'.
Importing cmdlet 'Add-BuildAttachment'.
Importing cmdlet 'Convert-String'.
Importing cmdlet 'Copy-BuildArtifact'.
Importing cmdlet 'Get-JavaDevelopmentKitPath'.
Importing cmdlet 'Get-MSBuildLocation'.
Importing cmdlet 'Get-ServiceEndpoint'.
Importing cmdlet 'Get-TaskVariable'.
Importing cmdlet 'Get-TfsClientCredentials'.
Importing cmdlet 'Get-ToolPath'.
Importing cmdlet 'Get-VisualStudioPath'.
Importing cmdlet 'Get-VssConnection'.
Importing cmdlet 'Invoke-Ant'.
Importing cmdlet 'Invoke-BatchScript'.
Importing cmdlet 'Invoke-Maven'.
Importing cmdlet 'Invoke-MSBuild'.
Importing cmdlet 'Invoke-Tool'.
Importing cmdlet 'Invoke-VSTest'.
Importing cmdlet 'Publish-BuildArtifact'.
Importing cmdlet 'Register-XamarinLicense'.
Importing cmdlet 'Unregister-XamarinLicense'.
Importing cmdlet 'Get-X509Certificate'.
Importing cmdlet 'Invoke-DeployTestAgent'.
Importing cmdlet 'Invoke-RunDistributedTests'.
Importing cmdlet 'Invoke-BlockEnvironment'.
Importing cmdlet 'Copy-FilesToAzureBlob'.
Importing cmdlet 'Copy-FilesToTargetMachine'.
Importing cmdlet 'Copy-ToAzureMachines'.
Importing cmdlet 'Remove-Environment'.
Importing cmdlet 'Remove-EnvironmentResources'.
Importing cmdlet 'Complete-EnvironmentOperation'.
Importing cmdlet 'Complete-EnvironmentResourceOperation'.
Importing cmdlet 'Complete-ResourceOperation'.
Importing cmdlet 'Get-Environment'.
Importing cmdlet 'Get-EnvironmentProperty'.
Importing cmdlet 'Get-EnvironmentResources'.
Importing cmdlet 'Get-ExternalIpAddress'.
Importing cmdlet 'Get-ParsedSessionVariables'.
Importing cmdlet 'Get-ProviderData'.
Importing cmdlet 'Invoke-EnvironmentOperation'.
Importing cmdlet 'Invoke-ResourceOperation'.
Importing cmdlet 'Invoke-PsOnRemote'.
Importing cmdlet 'New-OperationLog'.
Importing cmdlet 'Copy-FilesToRemote'.
Importing cmdlet 'Register-Environment'.
Importing cmdlet 'Register-EnvironmentDefinition'.
Importing cmdlet 'Register-Provider'.
Importing cmdlet 'Register-ProviderData'.
Importing cmdlet 'Invoke-UnblockEnvironment'.
Importing cmdlet 'Add-TaskIssue'.
Importing cmdlet 'Complete-Task'.
Importing cmdlet 'Find-Files'.
Importing cmdlet 'Get-LocalizedString'.
Importing cmdlet 'Set-TaskProgress'.
Importing cmdlet 'Set-TaskVariable'.
Importing cmdlet 'Write-TaskDetail'.
Importing cmdlet 'Enable-CodeCoverage'.
Importing cmdlet 'Publish-CodeCoverage'.
Exporting cmdlet 'Add-TaskIssue'.
Exporting cmdlet 'Complete-Task'.
Exporting cmdlet 'Find-Files'.
Exporting cmdlet 'Get-LocalizedString'.
Exporting cmdlet 'Set-TaskProgress'.
Exporting cmdlet 'Set-TaskVariable'.
Exporting cmdlet 'Write-TaskDetail'.
Importing cmdlet 'Add-TaskIssue'.
Importing cmdlet 'Complete-Task'.
Importing cmdlet 'Find-Files'.
Importing cmdlet 'Get-LocalizedString'.
Importing cmdlet 'Set-TaskProgress'.
Importing cmdlet 'Set-TaskVariable'.
Importing cmdlet 'Write-TaskDetail'.
Importing cmdlet 'Invoke-ResultPublisher'.
Importing cmdlet 'Publish-TestResults'.
Importing cmdlet 'Add-BuildArtifactLink'.
Importing cmdlet 'Add-BuildAttachment'.
Importing cmdlet 'Convert-String'.
Importing cmdlet 'Copy-BuildArtifact'.
Importing cmdlet 'Get-JavaDevelopmentKitPath'.
Importing cmdlet 'Get-MSBuildLocation'.
Importing cmdlet 'Get-ServiceEndpoint'.
Importing cmdlet 'Get-TaskVariable'.
Importing cmdlet 'Get-TfsClientCredentials'.
Importing cmdlet 'Get-ToolPath'.
Importing cmdlet 'Get-VisualStudioPath'.
Importing cmdlet 'Get-VssConnection'.
Importing cmdlet 'Invoke-Ant'.
Importing cmdlet 'Invoke-BatchScript'.
Importing cmdlet 'Invoke-Maven'.
Importing cmdlet 'Invoke-MSBuild'.
Importing cmdlet 'Invoke-Tool'.
Importing cmdlet 'Invoke-VSTest'.
Importing cmdlet 'Publish-BuildArtifact'.
Importing cmdlet 'Register-XamarinLicense'.
Importing cmdlet 'Unregister-XamarinLicense'.
Importing cmdlet 'Get-X509Certificate'.
Importing cmdlet 'Invoke-DeployTestAgent'.
Importing cmdlet 'Invoke-RunDistributedTests'.
Importing cmdlet 'Invoke-BlockEnvironment'.
Importing cmdlet 'Copy-FilesToAzureBlob'.
Importing cmdlet 'Copy-FilesToTargetMachine'.
Importing cmdlet 'Copy-ToAzureMachines'.
Importing cmdlet 'Remove-Environment'.
Importing cmdlet 'Remove-EnvironmentResources'.
Importing cmdlet 'Complete-EnvironmentOperation'.
Importing cmdlet 'Complete-EnvironmentResourceOperation'.
Importing cmdlet 'Complete-ResourceOperation'.
Importing cmdlet 'Get-Environment'.
Importing cmdlet 'Get-EnvironmentProperty'.
Importing cmdlet 'Get-EnvironmentResources'.
Importing cmdlet 'Get-ExternalIpAddress'.
Importing cmdlet 'Get-ParsedSessionVariables'.
Importing cmdlet 'Get-ProviderData'.
Importing cmdlet 'Invoke-EnvironmentOperation'.
Importing cmdlet 'Invoke-ResourceOperation'.
Importing cmdlet 'Invoke-PsOnRemote'.
Importing cmdlet 'New-OperationLog'.
Importing cmdlet 'Copy-FilesToRemote'.
Importing cmdlet 'Register-Environment'.
Importing cmdlet 'Register-EnvironmentDefinition'.
Importing cmdlet 'Register-Provider'.
Importing cmdlet 'Register-ProviderData'.
Importing cmdlet 'Invoke-UnblockEnvironment'.
Importing cmdlet 'Add-TaskIssue'.
Importing cmdlet 'Complete-Task'.
Importing cmdlet 'Find-Files'.
Importing cmdlet 'Get-LocalizedString'.
Importing cmdlet 'Set-TaskProgress'.
Importing cmdlet 'Set-TaskVariable'.
Importing cmdlet 'Write-TaskDetail'.
Importing cmdlet 'Enable-CodeCoverage'.
Importing cmdlet 'Publish-CodeCoverage'.
Exporting cmdlet 'Add-BuildArtifactLink'.
Exporting cmdlet 'Add-BuildAttachment'.
Exporting cmdlet 'Convert-String'.
Exporting cmdlet 'Copy-BuildArtifact'.
Exporting cmdlet 'Get-JavaDevelopmentKitPath'.
Exporting cmdlet 'Get-MSBuildLocation'.
Exporting cmdlet 'Get-ServiceEndpoint'.
Exporting cmdlet 'Get-TaskVariable'.
Exporting cmdlet 'Get-TfsClientCredentials'.
Exporting cmdlet 'Get-ToolPath'.
Exporting cmdlet 'Get-VisualStudioPath'.
Exporting cmdlet 'Get-VssConnection'.
Exporting cmdlet 'Invoke-Ant'.
Exporting cmdlet 'Invoke-BatchScript'.
Exporting cmdlet 'Invoke-Maven'.
Exporting cmdlet 'Invoke-MSBuild'.
Exporting cmdlet 'Invoke-Tool'.
Exporting cmdlet 'Invoke-VSTest'.
Exporting cmdlet 'Publish-BuildArtifact'.
Exporting cmdlet 'Register-XamarinLicense'.
Exporting cmdlet 'Unregister-XamarinLicense'.
Exporting cmdlet 'Get-X509Certificate'.
Processed: ##vso[task.setprogress value=-1;]
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.Internal.BootstrapperPath = D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
bootstrapperPath: D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerUsername = ********
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerPassword =
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.DbUsername =
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.DbPassword =
Running batch script.
Path: D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe
Arguments: end /d:sonar.login=********
WorkingFolder:
Entering ProcessWrapper.CreateStartInfo
workingFolder = D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild
filename = cmd.exe
arguments = /c ""D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\MSBuild.SonarQube.Runner.exe" end /d:sonar.login=********"
Leaving ProcessWrapper.CreateStartInfo
ProcessWrapper.Start - enter
ProcessWrapper.Start - starting process
ProcessWrapper.Start - process started
ProcessWrapper.Start - leave
Unhandled Exception: System.ComponentModel.Win32Exception: The directory name is invalid
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at SonarQube.Common.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
at SonarQube.TeamBuild.Integration.CoverageReportConverter.ConvertBinaryToXml(String converterExeFilePath, String inputBinaryFilePath, String outputXmlFilePath, ILogger logger)
at SonarQube.TeamBuild.Integration.CoverageReportConverter.ConvertToXml(String inputFilePath, String outputFilePath, ILogger logger)
at SonarQube.TeamBuild.Integration.CoverageReportProcessorBase.ProcessBinaryCodeCoverageReport(String binaryCoverageFilePath)
at SonarQube.TeamBuild.Integration.CoverageReportProcessorBase.ProcessCoverageReports()
at SonarQube.TeamBuild.PostProcessor.CoverageReportProcessor.ProcessCoverageReports()
at SonarQube.TeamBuild.PostProcessor.MSBuildPostProcessor.Execute(String[] args, AnalysisConfig config, ITeamBuildSettings settings)
at SonarQube.Bootstrapper.BootstrapperClass.PostProcess()
at SonarQube.Bootstrapper.BootstrapperClass.Execute()
at SonarQube.Bootstrapper.Program.Execute(String[] args, ILogger logger)
at SonarQube.Bootstrapper.Program.Main(String[] args)
at SonarQube.Old.Bootstrapper.Program.Main(String[] args)
SonarQube Scanner for MSBuild 3.0.2
Default properties file was found at D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from D:\a\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Post-processing started.
16:18:14.455 Fetching code coverage report information from TFS...
16:18:14.456 Attempting to locate a test results (.trx) file...
16:18:14.594 Looking for TRX files in: d:\a\1\TestResults, d:\a\1\s\TestResults
16:18:14.594 Located a test results file: d:\a\1\s\TestResults\buildguest_FACTORYVM-AZ203_2017-10-02_16_18_07.trx
System.Exception: Unexpected exit code received from batch file: -532462766
Processed: ##vso[task.logissue type=error;]System.Exception: Unexpected exit code received from batch file: -532462766
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeBatchScriptCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
The build was not triggered by a Pull Request, not processing code analysis comments
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.Internal.IncludeFullReport = true
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.Internal.ServerVersion =
Calling InvokeGetRestMethod "/api/server/version"
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.HostUrl = http://13.65.82.206/
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerUsername = ********
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerPassword =
GET http://13.65.82.206/api/server/version with 0-byte payload
received 11-byte response of content type text/plain
Processed: ##vso[task.setvariable variable=MSBuild.SonarQube.Internal.ServerVersion;]6.5.0.27846
The SonarQube server version is 6.5.0.27846
Waiting on the SonarQube server to finish processing in order to determine the quality gate status.
Invoke - Get-TaskVariable cmdlet
Variable read: Agent.BuildDirectory = d:\a\1
Could not find the task details file at d:\a\1\.sonarqube\out\.sonar\report-task.txt
System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
Processed: ##vso[task.logissue type=error;]System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
LegacyVSTSPowerShellHost.exe completed with return code: -1.
答案 0 :(得分:5)
请参阅以下步骤,通过Visual Studio测试任务运行DotNet Core Test:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform
值的特定位置选项
/framework:".NETCoreApp,Version=v2.0"