[英]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.