0

I have a bit of an issue after a build of a solution in an Azure Devops pipeline when compared to building on my local machine.

The pipeline build (In release mode) is adding various other sub folders for different packages like below....

enter image description here

However when I pull the latest code and build locally, my packages folder looks like this...

enter image description here

Because of this difference I'm struggling to run a nuget pack in my pipeline as it appears to be confused about which folder the package is in.

Missing C:\BuildAgent2\_work\2\s\packages\automapper\8.1.1\automapper.8.1.1.nupkg
Error NU5012: Unable to find 'AutoMapper.8.1.1.nupkg'. Make sure the project has been built.

Only a different version exists in the location returned by the error...

enter image description here

I'm stumped at what the problems are here. Can anybody help?

Thanks,

Konzy262
  • 2,747
  • 6
  • 42
  • 71
  • The info about your project types, project-solution structure, xx.csproj content, nuget.config file if you use and how you define the pipeline is very important for trouble-shooting. It'll be better if you can share more details above in your question. Or you can open a SO room and share the info there, I'll check for you directly. – LoLance Aug 25 '20 at 03:24
  • The solution contains a mixture of .net core and .net framework projects. There is no nuget.config file. The pipeline has a NuGet installer task with 5.6.0 specified. It then has a task that uses the restore command pointing at the solution file. We have a private feed as well as nuget.org. The destination directory is set as $(build.sourcesdirectory)\packages\. The solution is built using Visual Studio Build task. I attempt a nuget pack using pattern matching to point to my project `**\*.SEPA.Dto.csproj`. The same branch is referenced in 'Get Sources' as the branch I have cloned locally. – Konzy262 Aug 25 '20 at 07:49
  • The package that the error refers to exists in the agent folder here `C:\BuildAgent2\_work\2\s\packages\AutoMapper.8.1.1\AutoMapper.8.1.1.nupkg`. The package reference in the `.csproj` appears to be `..\packages\AutoMapper.8.1.1\lib\net461\AutoMapper.dll`. Happy to share further details if needed. What is an 'SO room'? – Konzy262 Aug 25 '20 at 07:54
  • I created a StackOverFlow chat room [here](https://chat.stackoverflow.com/rooms/220401/trouble-shooting-nuget), we can chat there to avoid too much comments. – LoLance Aug 25 '20 at 07:58

1 Answers1

1

packages folder has different contents

You should make sure the pipeline build fetched the same branch+commit source like your local build. Delete all the folders in packages folder and delete the nuget cache, download the nuget.exe 5.6.0 and add it to PATH environment variable so that your pipeline will use latest nuget.exe.

If your projects target .net core/.net standard, you should choose dotnet build task. Instead you should use Visual Studio Build task if your projects target .net framework.

Update: In most cases we should just leave the destination directory input blank.

enter image description here

LoLance
  • 25,666
  • 1
  • 39
  • 73