I've created a build pipeline for a .NET Framework project. When the pipeline is triggered by a pull request, I've got this errors on the task: 'NuGet restore'
##[error]The nuget command failed with exit code(1) and error(Error parsing solution file at
d:\a\1\s\***.sln
: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assemblyMicrosoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
or one of its dependencies. The system cannot find the file specified.d:\a\1\s\***.sln
)##[error]Packages failed to restore
When I try to compile the solution on my local computer after merging with the target branch, I don't have any conflicts or errors.
Here is my YML file:
pool:
name: Hosted Windows 2019 with VS2019
demands:
- msbuild
- visualstudio
- vstest
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2 # --> This task fails.
displayName: 'NuGet restore'
inputs:
restoreSolution: '***.sln'
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '***.sln'
platform: 'any cpu'
configuration: 'release'
- task: PublishSymbols@2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact drop'
inputs:
PathtoPublish: ***
ArtifactName: 'drop wa'
What's wrong with it?
There seems to be currently an issue with nuget task. You might try to change version to 5.4 as that seems to solve it for some people, including me.
Please see the link below: https://developercommunity.visualstudio.com/content/problem/978914/nuget-restore-on-hosted-agent-builds-cannot-find-s.html