Azure Devops Build fail with .deployproj with missing parameter "Language" error

dotnet
sonarcloud
azure

(Rafael Belanger) #1

Template for a good bug report, formatted with Markdown:

  • versions used: VSTS SonarCloud Version 1.4.0 - SonarScanner for MSBuild 4.4.1
  • error observed:
CreateProjectSpecificDirs:
2018-10-12T18:53:18.3982024Z   Creating directory "D:\a\1\.sonarqube\conf\0".
2018-10-12T18:53:20.4236768Z ##[error]D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(381,5): Error MSB4044: The "GetAnalyzerSettings" task was not given a value for the required parameter "Language".
2018-10-12T18:53:20.4251438Z D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(381,5): error MSB4044: The "GetAnalyzerSettings" task was not given a value for the required parameter "Language". [D:\a\1\s\AzureInfra\AzureInfra.deployproj]
2018-10-12T18:53:20.4618851Z Done Building Project "D:\a\1\s\AzureInfra\AzureInfra.deployproj" (default targets) -- FAILED.
  • VS 2017 solution with a Azure Resource Deployment project. Prepare analysis hasn’t changed. Build starting failing since release 1.4 on October 12 using SonarScanner for MSBuild 4.4.1. When solution is compiled in CI pipeline, builds crash with the error above.
  • potential workaround: Tried adding sonar.exclusions=*.deployproj in extraProperties of inputs but exclusion is not applied, build still fails.

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour


(Nikolai Blackie) #2

+1 for this issue. Have noticed the same thing and its killing my builds.


(Sebastian Kleu) #3

Hi,

We are noticing the same issue.
See error message below.

f:\BuildSource\VSTS1\6.sonarqube\bin\targets\SonarQube.Integration.targets(381,5): Error MSB4044: The “GetAnalyzerSettings” task was not given a value for the required parameter “Language”.
Process ‘msbuild.exe’ exited with code ‘1’.
f:\BuildSource\VSTS1\6.sonarqube\bin\targets\SonarQube.Integration.targets(381,5): Error MSB4044: The “GetAnalyzerSettings” task was not given a value for the required parameter “Language”.
Process ‘msbuild.exe’ exited with code ‘1’.

Is there any workaround? We started noticing this error message on 2018/10/12.


(Quintush) #4

Exclude the deployproj files using this documenation: https://docs.sonarqube.org/display/SCAN/Excluding+Artifacts+from+the+Analysis


(Sebastian Kleu) #5

@quintush,

Thank you. Excluding analysis fixed the build.


VSTS extension autoupdate to v4.4.0, fails build with 'not given a value for the required parameter "Language"'
(Scott McCollough) #6

I get the same error on an .sfproj. Same solution?


(luke) #7

Same problem, first noticed on 12/10/2018.
Unfortunately @quintush work around is not viable, as that would mean editing 30+ dcproj files, pull requests, approvals, etc etc. to work around a problem that did not exist a week ago.
Is there a fix planned by Sonarcloud. Or will this remain as expected behaviour and require customers to make dev changes to resolve?
Is anyone aware of a workaround that can be done in the build definition, this would be fine as it means 1 change in a task group common to all project build.


(Scott McCollough) #8

Maybe this?

{
  "name": "extraProperties",
  "type": "multiLine",
  "label": "Additional Properties",
  "defaultValue":
    "# Additional properties that will be passed to the scanner, \n# Put one key=value per line, example:\n# sonar.exclusions=**/*.bin",
  "required": false,
  "properties": {
    "resizable": "true",
    "rows": "5"
  },

(Scott McCollough) #9

I tired adding that to the yml build and it did not work.


(Rafael Belanger) #10

Solution suggested @quintush fixed it. Note that this fix requires to make changes to the solution files rather than sonar configurations.


(Scott McCollough) #11

This does work, but it doesn’t feel like a good fix.


(Riccardo Corradin) #12

Since we are using Azure devops and not annotating any SonarQube specific code in our .NET solution the provided workaround is not valid for us. What would also help is to specify a specific version of SonarQube to use instead of the latest 4.x version from wihin our build pipeline.
It broke our pipeline and our build agent, since it left the agent in an inconsistent state (all kind of SonarQube dll’s were not cleaned, resulting in even more errors).
To fix the agent, we had to move the “Run code analysis” task before the build, so that it could fail gracefully and clean up all the SonarQube dependencies. Hopefully this helps anyone.


(Mike Cooper) #13

Ya – not at all nice.
All things were running nicely in my Azure pipelines and Bang, all the C# builds start failing.

Did someone make a change behind the scenes?


(Curtis Hilgenberg) #14

Here’s a powershell script I wrote to automatically implement @quintush’s fix on all deployproj files in the Azure DevOps sources directory. I have it running towards the start of the build, before the SonarQube “prepare analysis” step.

Not the most elegant solution but it works.

$path = $env:BUILD_SOURCESDIRECTORY

$sonarExclude = @"
	</PropertyGroup>  
	<PropertyGroup>
	<!-- Exclude the project from analysis -->
	<SonarQubeExclude>true</SonarQubeExclude>
	</PropertyGroup>
"@

foreach($deployproj in Get-ChildItem -Path $path -Recurse -Filter *.deployproj)
{
	$content = Get-Content $deployproj.FullName
	[regex]$pattern = "</PropertyGroup>"
	$content = $pattern.replace($content, $sonarExclude, 1)
	Set-Content -Path $deployproj.FullName -Value $content
}

(Duncan Pocklington) #15

@all, the issue is being tracked by Scanner for MSBuild issue #589. We’ve released new versions of the scanner and the VSTS tasks to address the issue. Please let us know if you are still experiencing problems.
Please accept our apologies for the inconvenience.

Root cause: a property in one of our custom MSBuild tasks was marked as Required in version 4.4.1. The Scanner for MSBuild is embedded in the Azure DevOps SonarCloud and SonarQube extensions, which were re-released on Friday. The new versions of the extensions were minor updates, so they would have been automatically deployed by the build agents the next time a build using the task was executed.


VSTS extension autoupdate to v4.4.0, fails build with 'not given a value for the required parameter "Language"'
(Riccardo Corradin) #16

Thnx, works like a charm!


(Duncan Pocklington) #17

Thanks for the update @corradin!


(luke) #18

Thanks for the fix Duncan and keeping us all updated on the progress. Our builds with sonarcloud analysis are back to ‘green’. Yay.


(Duncan Pocklington) #19