Azure Devops流水线找不到al.exe。

4

我正在将本地的构建迁移到Azure DevOps。我正在使用默认的Azure构建代理,没有对默认代理配置进行任何指定。

这是构建管道YAML文件中引发错误的部分:

- 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'

此项目正在使用标准的Microsoft.Common.CurrentVersion.targets文件,但无法找到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.

我觉得这是我无法控制的事情。

做比较时,当我从命令行本地运行构建时,与构建相同部分的输出是:

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 

由于生成代理由 Azure 提供,我需要确定 SDK 工具的位置是否存在方法?
尽管https://dev59.com/gXA75IYBdhLWcg3w_uqD#42140667是针对 TeamCity 而非 Azure Devops 的,但该解决方案是指定不同路径到al.exe。 在这里我需要做类似的事情吗?
谢谢。

1
这似乎是托管代理的问题。根据日志,看起来您正在使用托管的 windows-2019 代理,请尝试使用 vs2017-win2016 并检查是否可行。另外,您还可以尝试在本地开发机器上设置私有代理,然后使用此私有代理运行构建以检查是否可行。 - Andy Li-MSFT
@AndyLi-MSFT,为什么使用旧的生成代理(vs2017-win2016)会有帮助呢?FYI我试过了,它解决了这些错误,但也暴露出其他问题。我的问题是:msbuild为什么无法在构建代理上找到最新版本的al.exe - Badgerspot
1个回答

3
根据日志记录,您似乎正在使用托管的 windows-2019 代理。默认情况下,windows-2019 代理未安装 NETFX 4.6.1 工具,因此无法在 "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\al.exe" 下找到 al.exe 文件。有关详细信息,请参见 托管的 Windows 2019
但是,NETFX 4.6.1 工具 已安装在 vs2017-win2016 代理上。因此,请尝试使用 vs2017-win2016 代理,而不是 windows-2019 代理。
您可以在管道中运行以下命令以检查每个代理上安装的 NETFX 工具版本:
cd 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin'
dir 

enter image description here

因此,要使用最新的 windows-2019 代理,您可以尝试直接在 [projectname].csproj 文件中指定 SDK 编辑路径,添加:
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools</TargetFrameworkSDKToolsDirectory>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接