繁体   English   中英

无法使用 Azure 管道中的 Paket 恢复 NuGet 包(工件馈送)

[英]Cannot restore NuGet packages using Paket in Azure Pipelines (Artifacts feed)

我正在尝试定义为.NET 核心解决方案构建的管道。 依赖项由Paket管理。 Azure 工件源下载依赖项。

在第一阶段,我认为问题出在 Paket 上,我能够定义一个无需它即可构建的管道(使用私有包源,我们的私有提要)。

一旦我修复了 Paket 问题,我在尝试让dotnet restore正常工作时遇到了问题。

这是我实际的 YML 定义:

trigger:
- none

pool:
  vmImage: 'windows-latest'

steps:
  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '3.1.x'

  - powershell: |
      cd ..
      dotnet tool install -g paket

  - task: setCredentialManager@0

  - task: PaketRestore@0
    inputs:
      PaketPath: '.paket'

  - task: paketCredentialCleanup@0

  # I'm not sure the following task is necessary
  - task: PowerShell@2
    inputs:
      filePath: './installcredprovider.ps1'

  - task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'config'
      nugetConfigPath: './NuGet.config'

  - task: CmdLine@2
    inputs:
      script: 'dotnet restore'

  - task: DotNetCoreCLI@2
    inputs:
      command: 'build'
      projects: '*.csproj'

NuGetCommand@2还原任务失败并显示以下日志:

NuGet Version: 5.4.0.6315
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
MSBuild P2P timeout [ms]: 120000
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\rjysskyy.m01.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\1cpdh2ma.wgd.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe" /p:RestoreSolutionDirectory="d:\a\1\s\\" /p:RestoreConfigFile="d:\a\1\s\NuGet.config" /p:SolutionDir="d:\a\1\s\\" /p:SolutionName="ArtifactsVs"
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
--- End of stack trace from previous location where exception was thrown ---
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
d:\a\1\s\.paket\Paket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:\a\1\s\ArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:\a\1\s\ArtifactsVs.csproj]
   at NuGet.CommandLine.RestoreCommand.<GetDependencyGraphSpecAsync>d__68.MoveNext()

--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.RestoreCommand.<DetermineInputsFromMSBuildAsync>d__63.MoveNext()
##[error]The nuget command failed with exit code(1) and error(EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:\a\1\s\ArtifactsVs.csproj]
d:\a\1\s\.paket\Paket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:\a\1\s\ArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:\a\1\s\ArtifactsVs.csproj])
##[error]Packages failed to restore
Finishing: NuGetCommand

无论如何省略它, dotnet restore都会失败。

脚本installcredprovider.ps1的来源在这里

可以从这里下载存储库(Feed URL 被部分混淆)。

提前感谢任何想提供帮助的人!

我创建了一个用于故障排除的测试项目。 我发现Paket需要.NET Core sdk 2.0.0

如果未安装 dotnet core 2.0.0,Nuget 恢复任务将失败,并出现上述错误"It was not possible to find any compatible framework version" 并且 paket retore 任务将失败并出现错误The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.

在我使用UseDotNet任务安装.NET Core sdk 2.0.0后。 Nuget 恢复和 paket 恢复都成功运行。 请查看以下 yaml:

pool:
  vmImage: 'windows-latest'

steps:

  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '2.0.0'

  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '3.1.x'

  - powershell: |
      cd ..
      dotnet tool install -g paket

  - task: setCredentialManager@0

  - task: PaketRestore@0
    inputs:
      PaketPath: '.paket'

  - task: paketCredentialCleanup@0

  # - task: PowerShell@2
  #   inputs:
  #     filePath: './installcredprovider.ps1'

  # - task: NuGetToolInstaller@1
  #   inputs:
  #     versionSpec: 5.x

  - task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/*.sln'
      feedsToUse: 'config'
      nugetConfigPath: './NuGet.config'

对于上述管道,任务setCredentialManager@0也是必须的,但不需要运行./installcredprovider.ps1的 powershell 任务。

而且我还发现上面的管道将无法在代理 vs2017-win2016 上运行,因为在执行 nuget 恢复命令时调用 vs2017 中的旧版本 msbuild。

Paket restore、dotnet restore 和 nuget restore 它们都做同样的事情(dotnet restore 和 nuget restore 将调用 paket restore)。 您只能将其中一个保留在您的管道中。 我进行了测试,我的项目使用其中任何一个都成功构建了。

以上希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM