1
votes

my problem is that I have a project created in .net core 2.2, the problem is that I am trying to deploy it with azure pipelines but when using the dotnet restore it fails continuously and ends the construction.

The error it returns is the following:

2020-11-21T20:17:30.4639428Z ##[error]**Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1**

2020-11-21T20:17:30.4652823Z ##[error]**Packages failed to restore**

2020-11-21T20:17:30.4655465Z **Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.1) SDK/Runtime along with 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.**
 
2020-11-21T20:17:30.4656214Z Some commonly encountered changes are: 
2020-11-21T20:17:30.4657227Z If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2020-11-21T20:17:30.4661682Z ##[section]Finishing: dotnet restore

I have tried to install version 2.2 to be used in the process before the restore, I have tried using the nuget.config and the global.json.I leave here the .yml that I have used to see if someone can give me a hand.

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 2.2.x'
  inputs:
    version: 2.2.x
    includePreviewVersions: true
    performMultiLevelLookup: true

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1
    checkLatest: true

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()
1
I used your pipeline to test it on minimal solution and it works. Can you try to do the same?Krzysztof Madej

1 Answers

2
votes

I've tested with a .net core 2.2 project using the following yaml file, and got successful result.

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
  - task: UseDotNet@2
    inputs:
      version: '2.2.x'
      includePreviewVersions: true
      performMultiLevelLookup: true
  - task: DotNetCoreCLI@2
    inputs:
      command: 'restore'
      projects: '**/*.csproj'

In order to narrow down the issue, I'd like to suggest you:

  1. Create a simple .net core 2.2 project and push to DevOps, create a pipeline for this project to see whether you can reproduce this issue.
  2. Clone the project to local, and run dotnet restore command locally to see how's the result.