sdk: "dotnet pack" does not build
According to the documentation (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack) the command dotnet pack should first build the project, unless the option --no-build is specified.
I am using Github Actions to publish my nuget project. And in my yml after setting up the environment and checking out the code I run the command dotnet pack --configuration Release -o output, which worked fine before but after my latest changes (renaming files, no changes to the yml) it fails with
##[error]/opt/hostedtoolcache/dncs/3.1.101/x64/sdk/3.1.101/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(198,5): error NU5026: The file ‘/home/runner/work/IvanStoychev.StringExtensions/IvanStoychev.StringExtensions/IvanStoychev.StringExtensions/bin/Release/netcoreapp3.0/IvanStoychev.StringExtensions.dll’ to be packed was not found on disk.
If I were to place a dotnet build command before the packing - it works fine.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 17 (4 by maintainers)
Commits related to this issue
- Fix for https://github.com/dotnet/sdk/issues/12160 — committed to Drake53/NuGetPush by Drake53 2 years ago
- Apply workaround for issue https://github.com/dotnet/sdk/issues/12160 — committed to GennadyGS/DotNetUtils by GennadyGS a year ago
- dotnet: ensure native libraries are included with the release See https://github.com/dotnet/sdk/issues/12160#issuecomment-1148324465 I don't entirely understand what's happening here, but adding th... — committed to tigerbeetle/tigerbeetle by matklad 8 months ago
I know this is an older issue but if someone is still having the same issue this worked for me: https://steveellwoodnlc.medium.com/error-nu5026-the-file-to-be-packed-was-not-found-on-disk-18bfbc6be4a
Simply remove this from your csproj file if you have it:
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>I can confirm that this issue also exists on my mac running dotnet
6.0.301. I have library projects with<GeneratePackageOnBuild>true</GeneratePackageOnBuild>set. Setting<GeneratePackageOnBuild>false</GeneratePackageOnBuild>fixes the problem as suggested by @AntonSmolkovany update on this?
I can confirm this was an issue for us on Windows.
dotnet packwas packaging old assemblies under new version numbers, causing a lot of confusion.Removing the
GeneratePackageOnBuildelement from the csproj, as suggested above, worked for us.6.0.202, the issue is still presented. Workaround:
Still seems to be an issue as of:
.NET SDK (reflecting any global.json): Version: 5.0.203 Commit: 383637d63f
Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.203\
Host (useful for support): Version: 5.0.6 Commit: 478b2f8c0e
.NET SDKs installed: 3.1.111 [C:\Program Files\dotnet\sdk] 5.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Removing the GeneratePackageOnBuild tag as mentioned does indeed allow “dotnet pack” at the CLI to build the solution first.
This however seems counterintuitive to enabling that setting in the first place if one were to expect a pack as output from a build performed directly within the (VS2019) IDE.
Hi folks,
If this is still an issue, can someone provide more details? The following would be helpful:
I found that my project didn’t build success by dotnet pack.
See:
https://github.com/dotnet-campus/dotnetCampus.CommandLineArgsViewer/runs/881667779
https://github.com/dotnet-campus/dotnetCampus.WPFType/actions/runs/173374599
https://github.com/dotnet-campus/dotnetCampus.WPFType/actions/runs/173373439
https://github.com/dotnet-campus/dotnetCampus.WPFType/actions/runs/173372612
https://github.com/dotnet-campus/dotnetCampus.CommandLineArgsViewer/runs/883890812