Pack and Push Errors

This section documents MSBuild 18.9, the .NET SDK 10.0.402 (with its dotnet CLI) and NuGet 7.9, as published in the MSBuild, .NET and NuGet documentation on learn.microsoft.com, which is the reference these pages are written and verified against. Material about .NET 11 / NuGet 8.0 is still in preview and is always flagged as such — never presented as baseline.

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

The C# Reference bibliography lists the reference material consulted while preparing these pages.

This page collects the diagnostics from the publishing group in one place. Messages marked (run) were produced in this section with .NET SDK 10.0.402 (NuGet 7.9.0), from one-file projects or the Ledgerline scenario, and are quoted as printed (paths shortened, the [project] suffix removed); the others are quoted from their reference page and say so. Each code links to its NuGet reference page. Consumer-side codes (restore, audit, sources) are on Troubleshooting NuGet Errors and Warnings.

Metadata

Code Message Fix

NU5030

error NU5030: The license file 'LICENSE.txt' does not exist in the package. (run)

Pack the file: None Include="LICENSE.txt" Pack="true" PackagePath="".

NU5032

error NU5032: The license expression 'GPL-2.0' cannot be parsed succesfully. The identifier 'GPL-2.0' is deprecated. (run)

Use a current SPDX identifier (GPL-2.0-only).

NU5033

error NU5033: Invalid metadata. Cannot specify both a PackageLicenseExpression and a PackageLicenseFile. (run)

Keep one.

NU5035

error NU5035: The PackageLicenseUrl is being deprecated and cannot be used in conjunction with the PackageLicenseFile or PackageLicenseExpression. (run)

Remove PackageLicenseUrl.

NU5038

error NU5038: The readme file 'readme.txt' has an invalid extension. It must end in .md. (run)

Use Markdown.

NU5039

error NU5039: The readme file 'README.md' does not exist in the package. (run)

Pack the README.

NU5040

error NU5040: The readme file 'README.md' is empty. (run)

Write it.

NU5045

error NU5045: The 'icon' element 'icon.bmp' has an invalid file extension. Valid options are .png, .jpg or .jpeg. (run)

PNG or JPEG.

NU5046

error NU5046: The icon file 'icon.png' does not exist in the package. (run)

Pack the icon.

NU5047

error NU5047: The icon file size must not exceed 1 megabyte. (run)

Shrink it; 128×128 is enough.

NU5048

warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl (run)

Embed the icon with PackageIcon.

NU5052

Documented as a warning about IDs outside letters, digits, dots and dashes. On 10.0.402 invalid IDs failed with uncoded errors instead: error : The package ID 'Ledger line!' contains invalid characters. ... and error : Id must not exceed 100 characters. (run)

Fix the PackageId.

NU5124

warning NU5124: The license identifier 'Foo-1.0' is not recognized by the current toolset. (run)

Check the SPDX list; nuget.org validates on upload.

NU5125

warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead. (run)

Use PackageLicenseExpression or PackageLicenseFile.

Contents and layout

Code Message Fix

NU5017

error NU5017: Cannot create a package that has no dependencies nor content. (run)

Something must be packed.

NU5026

error NU5026: The file '.../bin/Release/net10.0/NoBuild.dll' to be packed was not found on disk. (run)

Build before --no-build.

NU5049

"The pack command for SDK-style projects is not supported, use dotnet pack or msbuild -t:pack to pack this project instead. …​" (documented; nuget.exe pack)

Use dotnet pack.

NU5051

error NU5051: This project is using aliased frameworks, the following TargetFramework properties map to the same effective frameworks 'apple, banana => net10.0' and pack is unable to disambiguate ... (run)

IncludeBuildOutput=false and SuppressDependenciesWhenPacking=true on all but one alias.

NU5100

warning NU5100: The assembly 'other/Other.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project. ... (run)

Expected for tool, task and analyzer packages; otherwise move it to lib/<tfm>/.

NU5101

warning NU5101: The assembly 'lib/Other.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder. ... (run)

Use lib/<tfm>/.

NU5104

warning NU5104: A stable release of a package should not have a prerelease dependency. Either modify the version spec of dependency "Ledgerline.Preview [1.0.0-beta.1, )" or update the version field in the nuspec. (run)

Prerelease this package too, or wait for a stable dependency.

NU5118

warning NU5118: File '.../Dup/b/x.txt' is not added because the package already contains file 'content/x.txt' (run)

One item per PackagePath.

NU5119

"File '…​\Libuv.1.10.0.nupkg' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. …​" (documented; an explicit item for a dot-folder packed without it on 10.0.402)

NoDefaultExcludes, or don’t pack it.

NU5123

warning NU5123: The file 'content/ddd.../fff....txt' path, name, or both are too long. Your package might not work without long file path support. Shorten the file path or file name. (run; installed path over 200 characters)

Shorten it.

NU5127

warning NU5127: This package does not contain a lib/ or ref/ folder, and will therefore be treated as compatible for all frameworks. Since framework specific files were found under the build/ directory for net8.0, consider creating the following empty files to correctly narrow the compatibility of the package: -lib/net8.0/_._ (run)

Add the _._ placeholder.

NU5128

warning NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. ... (run)

Align folders and groups, or suppress for build-only packages.

NU5129

warning NU5129: - At least one .props file was found in 'build/', but 'build/BuildPropsName.props' was not. (run)

Name the file after the package ID.

NU5131

warning NU5131: - Add C.dll to the net8.0 reference group in the nuspec (run, with NU5128)

Match ref/ assemblies and reference groups.

NU5501

"The following dependency group(s) require(s) dots in the framework version: net50-windows7.0" (documented; a hand-written net50 group was normalized to net5.0 by dotnet pack without a warning)

Write net5.0.

Validation and tools

Code Message Fix

CP0001

error CP0001: Type 'Ledgerline.LegacyHelpers' exists on lib/netstandard2.0/Ledgerline.dll but not on lib/net8.0/Ledgerline.dll (run)

Same public API on compatible frameworks.

CP0002

error CP0002: Member 'System.Collections.Generic.IReadOnlyList<Ledgerline.JournalLine> Ledgerline.LedgerReader.ReadFile(string)' exists on [Baseline] lib/net10.0/Ledgerline.dll but not on lib/net10.0/Ledgerline.dll (run)

Restore the member, or suppress for a major version.

CP0003

error CP0003: lib/net10.0/Ledgerline.dll assembly version '1.1.0.0' should be equal to [Baseline] lib/net10.0/Ledgerline.dll version '1.0.0.0'. (run, strict mode)

Strict mode is for patch releases.

PKV006

error PKV006: Target framework .NETStandard,Version=v2.0 is no longer supported in the latest version. (run)

Keep the framework, or suppress for a major version.

NETSDK1047

error NETSDK1047: Assets file '.../obj/project.assets.json' doesn't have a target for 'net10.0/any'. ... (run; any only in ToolPackageRuntimeIdentifiers)

Add any to RuntimeIdentifiers too.

NETSDK1235

warning NETSDK1235: .NET Tools do not support using a custom .nuspec file, but the nuspec file 'custom.nuspec' was provided. ... (documented; .NET 11 SDK)

Drop NuspecFile from tool projects.

Signing

Code Message Fix

NU3002

warn : NU3002: The '--timestamper' option was not provided. The signed package will not be timestamped. ... (run)

Pass --timestamper.

NU3018

error: NU3018: InvalidBasicConstraints: key usage does not include certificate signing (run, sign) and error: NU3018: The author primary signature's signing certificate is not trusted by the trust provider. (run, verify)

A valid chain; for test certificates, trust author --allow-untrusted-root.

NU3027

warn : NU3027: The signature should be timestamped to enable long-term signature validity after the certificate has expired. (run)

Timestamp the signature.

NU3034

error: NU3034: signatureValidationMode is set to require, so packages are allowed only if signed by trusted signers; however, no trusted signers were specified. (run)

Add trustedSigners.

NU3042

warn : NU3042: The following X.509 root certificate is untrusted because it is not present in the certificate bundle at .../trustedroots/codesignctl.pem. ... (run, Linux)

Expected for test certificates.

Details: Signing Packages.

Push

Status Message Cause

401

error: Response status code does not indicate success: 401 (Unauthorized). (run, BaGetter, wrong or missing key)

Wrong, expired or missing API key; on nuget.org also a key from another owner.

403

Not reproduced. Documented causes: Azure Artifacts without the Feed Publisher (Contributor) role; GitHub Packages intermittently during restore without source mapping.

Grant the role; add source mapping.

409

Conflict ... To skip already published packages, use the option --skip-duplicate / error: Response status code does not indicate success: 409 (Conflict). (run, BaGetter)

The version exists; publish a new one or use --skip-duplicate.

413

error: Response status code does not indicate success: 413 (The package file exceeds the size limit. Please try again.). (documented, nuget.org)

Packages over about 250 MB; split them.

nuget.org’s own wording for 409 and for a key whose scope doesn’t cover the package is not documented; the codes are the same, the messages above come from BaGetter.