0
votes

I am having a weird problem with Azure DevOps, which is that dotnet restore can restore nuget packages successfully but dotnet build failed because the packages cannot be found.

Here is the steps in my pipeline, as well as some output from each steps

  1. dotnet restore

In this step, I specifically set the Destination to packages folder in root so that I can verify that packages are actually stored. In addition, since I am using private nuget repo, I specify the NuGet.config file and the credentials.

  1. ls && ls packages

I would like to make sure packages are restored so I add this step. From the output, I can see that packages from both nuget repo and my private repo are there

  1. dotnet build

I get error in this step (not always. this step will be succeed occasionally, sometimes after I update some pipeline config). In this step, the error says

The type or namespace name 'Migrations' does not exist in the namespace 'Microsoft.EntityFrameworkCore' (are you missing an assembly reference?)

For this step, I also tried to use PowerShell with command dotnet build Booking.Server.csproj -c Release --no-restore --source ..\packages and I got the same error.

===========================================

In addition, I also checked my csproj file that no package is referenced from a local path.

Can anyone please help?

Thank you.

============================================= Update yaml file

pool:
  name: Azure Pipelines
steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    feedsToUse: config
    nugetConfigPath: Booking.Server/NuGet.config
    externalFeedCredentials: 'GitLab Nuget Repository'
    restoreDirectory: packages
    verbosityRestore: Diagnostic

- powershell: |
   ls
   ls packages
   ls packages/booking.shared
   
  displayName: 'Check pakcages'

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: Booking.Server
    arguments: '-c Release --no-restore --source ..\packages'
    workingDirectory: Booking.Server
  enabled: false

- powershell: |
   ls
   ls ..
   ls ../packages
   dotnet build Booking.Server.csproj -c Release --no-restore --source ..\packages --verbosity diag
  workingDirectory: Booking.Server
  displayName: Build
1
Can you provide the yamls/ screenshot of the steps with all config values?Repcak
Hi @Repcak, the yaml has been attached in the question. Thank youBen

1 Answers

0
votes

The probable cause of this problem is your path points to the incorrect packages folder, especially the confusion between folders and subfolders. You can refer to this blog.