SonarQube VSTS任务版本3.0.1无法支持多种msbuild类型吗?

时间:2017-07-28 14:29:50

标签: c# msbuild sonarqube sonarqube-scan

我正在尝试使用SonarQube任务定位dotnetcore解决方案,但在解决方案中有几个使用dotnetstandard框架的项目。因此,在尝试分析代码时,新的SonarQube任务会抛出一个错误,指出它无法找到Microsoft.Build.Utilities.v4.0,如下所示:

2017-07-26T20:33:04.5685747Z 
[C:\agent\_work\6\.sonarqube\bin\targets\SonarQube.Integration.targets(166,5): error MSB4062: The "IsTestFileByName" task could not be loaded from the assembly C:\agent\_work\6\.sonarqube\bin\SonarQube.Integration.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. 
[C:\agent\_work\6\s\PSG.Identity.Contracts\PSG.Identity.Contracts.csproj]

2017-07-26T20:33:05.1623435Z ## [错误]错误:C:\ Program Files \ dotnet \ dotnet.exe失败,返回码:1

IntegrationTest项目是在dotnetcore框架上编写的,但该项目引用了在dotnetstandard框架上编写的2个项目。是否可以让此任务支持多个框架?

1 个答案:

答案 0 :(得分:2)

根据您发布的输出,您似乎使用的是dotnet命令dotnet builddotnet msbuild

根据此链接https://www.sonarsource.com/resources/product-news/news.html#2017-04-13-sonarqube-scanner-for-msbuild-2-3-released sonarqube-scanner-msbuild仅支持MSBuild 15或更高版本。

因此,请尝试直接使用msbuild而不是dotnet命令。 如果您在ci环境中执行此操作,则可能需要安装msbuild tools 2017。下载位于页面底部。

另外,请确保您使用的是sonarqube-scanner-msbuild