3
votes

I'm migrating an on-prem build onto Azure Devops. I am using a default Azure build agent with nothing specified over the default agent config.

Here is the part of the build pipeline YAML that is throwing an error:

- task: NuGetCommand@2
  displayName: 'Build Assemblies: Restore'
  inputs:
    command: 'restore'
    restoreSolution: '$(FooSolutionSolution)'
    feedsToUse: 'config'

- task: VSBuild@1
  displayName: 'Build Assemblies: Run'
  inputs:
    solution: '$(FooSolutionSolution)'
    platform: '$(FooSolutionBuildPlatform)'
    configuration: '$(buildConfiguration)'
    msbuildArgs: '-t:rebuild'

It is using the standard Microsoft.Common.CurrentVersion.targets file but is failing to find al.exe.

CoreCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\vbc.exe /noconfig /imports: {..imports..} /optioncompare:Binary /optionexplicit+ /optionstrict+ /optioninfer+ /nostdlib /platform:AnyCPU /rootnamespace:FooCorp.Central /sdkpath:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1" /highentropyva+ /define:"CONFIG=\"Release\",TRACE=-1,_MyType=\"Windows\",PLATFORM=\"x64\"" /reference: {..references ..} /main:"FooCorp.Central.(None)" /debug- /keyfile:d:\a\1\s\Builds\FooCorpKey\FooCorpKey.snk /optimize+ /out:.\obj\x64\Release\FooSolution\FooCorp.Central.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /resource:.{..resources..}  /target:library /warnaserror+ /utf8output /langversion:14 AssemblyInfo.vb {..all other vb files..} "C:\Users\VssAdministrator\AppData\Local\Temp\.NETFramework,Version=v4.5.1.AssemblyAttributes.vb"
  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
GenerateSatelliteAssemblies:
  Creating directory ".\obj\x64\Release\FooSolution\es".
  Creating directory ".\obj\x64\Release\FooSolution\ru".
  Creating directory ".\obj\x64\Release\FooSolution\zh-CN".
  Creating directory ".\obj\x64\Release\FooSolution\lb-LU".
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3639,5): 
Error MSB6004: The specified task executable location "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\al.exe" is invalid.

This is something that I don't think I can control.

For comparison when I run the build locally from the command line the output from the same part of the build is:

GenerateSatelliteAssemblies:
  C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\al.exe /culture:zh-CN /keyfile:C:\s-gl\Builds\FooCorpKey\FooCorpKey.snk /out:.\obj\x64\Release\FooSolution\zh-CN\FooCorp.Central.Lic.resources.dll /platform:AnyCPU /template:.\obj\x64\Release\FooSolution\FooCorp.Central.Lic.dll /embed:.\obj\x64\Release\FooSolution\FooCorp.Central.Lic.a1.zh-CN.resources /embed:.\obj\x64\Release\FooSolution\FooCorp.Central.Lic.a2.zh-CN.resources /embed:.\obj\x64\Release\FooSolution\FooCorp.Central.Lic.a3.zh-CN.resources 

As the build agent is supplied by Azure is there a way I can determine where the SDK tools are located?

Although https://stackoverflow.com/a/42140667 was reported for TeamCity not Azure Devops the solution there was to specify a different path to al.exe . Do I need to do something similar here?

Thanks

1
It seems a hosted agent issue. According to the logs, it appears that you are using the hosted windows-2019 agent, please try using vs2017-win2016 and check if that works. In addition, you can also try to setup a private agent on your local develop machine, then run the build with this private agent to check if that works.Andy Li-MSFT
@AndyLi-MSFT why would using an older build agent (vs2017-win2016) help? FYI I tried it an it resolved these errors but exposed others. My question here is why can msbuild not find the latest version of al.exe on the build agent?Badgerspot

1 Answers

2
votes

According to the logs, it appears that you are using the hosted windows-2019 agent.

By default the NETFX 4.6.1 Tools are not installed on the windows-2019 agent. So it cannot find the al.exe file under "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\al.exe". See Hosted Windows 2019 for details.

However the NETFX 4.6.1 Tools are installed on vs2017-win2016 agent. So, please try using vs2017-win2016 agent instead of the windows-2019 agent.

You can run the following commands in pipeline to check the installed versions of NETFX tools on each of the agents:

cd 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin'
dir 

enter image description here

So, to use the latest windows-2019 agent, you can try to specify the path to the SDK editing directly in the [projectname].csproj file, add:

<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools</TargetFrameworkSDKToolsDirectory>