Bijington
Bijington

Reputation: 3751

Azure DevOps NuGet task just started failing (missing dotnet core)

I have recently discovered that my Azure DevOps pipeline has started failing. Originally I assumed I had broken it with my recent changes however if I run the same commit on the same branch (NOTE that I have renamed master to main) then it fails when it had previously succeeded:

enter image description here

Here is my YAML for the pipeline:

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: NuGetCommand@2
  displayName: "NuGet Restore"
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'

- task: MSBuild@1
  displayName: "NET 4.0 Build"
  inputs:
    solution: '**\Expressive.csproj'
    configuration: 'Release'

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: '**/*.csproj'
    testRunTitle: 'Run all tests'

I have discovered this detail in the build log:

Errors in D:\a\1\s\Source\CSharp\Expressive\Expressive.Tests\Expressive.Tests.csproj
    Unable to resolve 'Microsoft.NETCore.App (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.0.0/microsoft.netcore.dotnethostresolver.2.0.0.nupkg 39ms
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.2.0/microsoft.netcore.dotnethostresolver.2.2.0.nupkg 37ms
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.1.0/microsoft.netcore.dotnethostresolver.2.1.0.nupkg 38ms
  OK https://api.nuget.org/v3-flatcontainer/system.runtime.serialization.json/4.0.2/system.runtime.serialization.json.4.0.2.nupkg 953ms
  OK https://api.nuget.org/v3-flatcontainer/system.xml.xpath.xmldocument/4.0.1/system.xml.xpath.xmldocument.4.0.1.nupkg 955ms

So to summarise the only difference I can see is the fact that I have renamed master to main. I would be rather surprised if this is the cause of the problem though. Has anyone seen this or are able to provide assistance?

Upvotes: 0

Views: 449

Answers (1)

Hugh Lin
Hugh Lin

Reputation: 19361

Update:

As workaround , switch to dotnet restore task to solve this issue .

Troubleshooting:

You can try to check the nuget version used by the nuget restore task in the pipeline running on the master branch. Then compare it with the nuget version used in pipeline running on the main branch to see if they are consistent.

enter image description here

If they are inconsistent, you can add a NuGet tool installer task to the main branch pipeline to use the same nuget version as the master branch pipeline.

enter image description here

Upvotes: 1

Related Questions