【问题标题】:Azure Devops Build Fail when using GeneratePathProperty true for PackageReference对 PackageReference 使用 GeneratePathProperty true 时 Azure Devops 构建失败
【发布时间】:2020-06-22 09:14:13
【问题描述】:

我们在 Visual Studio 中设置了一个项目,我们在其中使用 NuGet 包引用。对于其中一个 NuGet 包,我们将 GeneratePathProperty 设置为 true,以便我们可以将文件从 NuGet 包位置复制到项目的 Output bin 文件夹中

他已将 .csproj 文件配置如下:

<PackageReference Include="ilmerge" GeneratePathProperty="true">
  <Version>3.0.29</Version>
</PackageReference>
<None Include="$(Pkgilmerge)\tools\net452\ILMerge.exe">
  <Link>ILMerge.exe</Link>
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="$(Pkgilmerge)\tools\net452\System.Compiler.dll">
  <Link>System.Compiler.dll</Link>
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

这在本地工作得非常好(使用 Visual Studio 2019) - 项目编译和文件被复制到 bin 文件夹,但是在我们的构建管道中使用 windows-2019 托管代理(根据文档@也应该有 VS 2019) 987654321@) 这在构建任务期间失败:

[错误]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4601,5):错误 MSB3030:无法复制文件'd:\tools\net452\ILMerge.exe' 因为找不到。

[错误]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4601,5):错误 MSB3030:无法复制文件'd:\tools\net452\System.Compiler.dll' 因为找不到。

构建定义有以下任务

steps:
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
  displayName: 'Restore Nugets'
  inputs:
    restoreSolution: '$(solutions)'
    vstsFeed: 'Project-Packages'

- task: VSBuild@1
  inputs:
    solution: '$(solutions)'
    platform: 'Any CPU'
    configuration: 'Release'
    logProjectEvents: false

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.StagingDirectory)'
    artifactName: $(pluginName)
  condition: always()

任何想法可能是什么问题或我们需要更改什么才能使 Azure DevOps 中的构建工作?

稍后编辑:我添加了一些日志记录

  <Target Name="¨ReMerge" AfterTargets="ILRepacker" >
    <Message Text="Remerging Assemblies using ILMerge from $(Pkgilmerge) and setting AssemblyVersion = 2.0.0.0" Importance="High" />
    <Exec Command="dir $(Pkgilmerge)"></Exec>
    <Exec Command="$(Pkgilmerge)\tools\net452\ILMerge.exe /ver:2.0.0.0 /out:$(TargetDir)$(TargetName)Merged.dll /keyfile:$(ProjectDir)Zurich.Zkp.Key.snk $(TargetDir)$(TargetName)MergedTemp.dll"></Exec>
  </Target>

似乎在 AzureDevops 中 $(Pkgilmerge) 是空的

谢谢

【问题讨论】:

    标签: visual-studio azure-devops msbuild nuget


    【解决方案1】:

    上述错误是由旧版本(4.x)Nuget 用于恢复您的解决方案引起的。

    您需要为您的 NuGetToolInstaller 任务指定最新的 Nuget 版本,如果未指定,将自动选择一个版本。

    查看以下示例以指定 NuGetToolInstaller 任务以使用 5.4.x 版本的 Nuget。

    - task: NuGetToolInstaller@0
      inputs:
        versionSpec: 5.4.x
    

    【讨论】:

    • 谢谢李维斯。我已经进行了建议的更改,现在构建是绿色的。非常感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    • 1970-01-01
    相关资源
    最近更新 更多