我正试图定义一个为.NETCore解决方案构建的管道。依赖项由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:a1sArtifactsVs.csproj]
MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentbin'. 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:a1sArtifactsVs.csproj]
MSBuild P2P timeout [ms]: 120000
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentbinmsbuild.exe "C:UsersVssAdministratorAppDataLocalTempNuGetScratchrjysskyy.m01.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:UsersVssAdministratorAppDataLocalTempNuGetScratch1cpdh2ma.wgd.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="C:hostedtoolcachewindowsNuGet5.4.0x64nuget.exe" /p:RestoreSolutionDirectory="d:a1s\" /p:RestoreConfigFile="d:a1sNuGet.config" /p:SolutionDir="d:a1s\" /p:SolutionName="ArtifactsVs"
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.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:a1sArtifactsVs.csproj]
at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.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:a1sArtifactsVs.csproj]
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
d:a1s.paketPaket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:a1sArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:a1sArtifactsVs.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:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
EXEC : Standard error : It was not possible to find any compatible framework version [d:a1sArtifactsVs.csproj]
d:a1s.paketPaket.Restore.targets(219,5): error MSB3073: The command ""paket" restore --project "d:a1sArtifactsVs.csproj" --output-path "obj" --target-framework "netcoreapp3.1"" exited with code 1. [d:a1sArtifactsVs.csproj])
##[error]Packages failed to restore
Finishing: NuGetCommand
不管怎样,省略它,dotnet restore
也会失败。
脚本installcredprovider.ps1
的来源在这里。
存储库可以从这里下载(提要URL被部分混淆(。
提前感谢任何想帮忙的人!
我创建了一个用于故障排除的测试项目。我发现帕基特需要.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 restore命令时调用了vs2017中的旧版本msbuild。
Paket restore、dotnet restore和nuget restore它们都做相同的事情(dotnet restore-nuget restore将称为Paket-restore(。你只能保留其中一个。我进行了测试,我的项目用其中任何一个都成功构建了。
希望以上帮助!