error NU5026: The file ‘…’ to be packed was not found on disk.

Steve Ellwood
1 min readDec 3, 2020

--

This randomly started happening to me shortly after .NET 5 was released, which I realise may well be just a concidence. It was however affecting some of my libraries that target NetStandard2.0 and net471. Strangely the build passed regardless of how I did it — sometimes for example NCrunch shows up issues that aren’t otherwise clear but it was showing nothing, however when I try to pack the library I get —

C:\Program Files\dotnet\sdk\3.1.302\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(198,5): error NU5026: The file ‘…\bin\Release\net471\MyLibrary.dll’ to be packed was not found on disk. […\MyLibrary.csproj]

The solution turned out to be remarkably simple but equally frustrating — I have the following line in some of my libraries as I use it in my CI.

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

Removing that line fixes the issue — I just need to fix all my CI that used it now!

--

--

Steve Ellwood

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.