Azure 管道失败并显示警告 MSB3246:已解析文件的图像不正确

Azure pipeline fails with Warning MSB3246: Resolved file has a bad image

我无法使用 Azure 在 .Net 5.0 中构建一个解决方案,该解决方案引用了一个简单的 DLL,内置于任何 CPU/版本中,在带有 VS2019 的 x64 机器上。 当它尝试加载 DLL 时,Azure 抱怨:

Warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'xxx.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format

该项目在本地运行良好,两个项目(构建 DLL 和 Azure 必须构建的项目)都在 .Net 5.0 中,默认“Any CPU”配置,没有什么特别之处。 我想将它保留在“Any CPU”中,而不必定义任何自定义构建平台/配置,就像在开发机器上所做的那样。

这是 yaml 管道文件的(稍微简化的)开头:

trigger: - develop

pool: vmImage: 'windows-latest'

variables: solution: './Projects/**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release'

steps:

  • task: NuGetToolInstaller@1

  • task: NuGetCommand@2 inputs: restoreSolution: '$(solution)'

  • task: VSBuild@1 inputs: solution: '$(solution)' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)'

是否有特定参数可提供给 Azure 以使其与简单的已构建“任何 CPU”DLL 一起工作?

在 YAML 构建中,添加 a checkout step with lfs set to true:

steps:
- checkout: self
  lfs: true

如果没有它,文件将替换为 lfs 下载位置的占位符。

这里是你可以参考