Skip to content

fix: produce valid NuGet packages from package nuget create - #632

Open
NickJosevski wants to merge 2 commits into
mainfrom
nj/fix-477
Open

fix: produce valid NuGet packages from package nuget create#632
NickJosevski wants to merge 2 commits into
mainfrom
nj/fix-477

Conversation

@NickJosevski

@NickJosevski NickJosevski commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #477

Problem

package nuget create wrote the nuspec and the matched files into a zip and named it .nupkg. A .nupkg is an Open Packaging Conventions container, not a plain zip, so the result was missing every OPC part:

$ unzip -l Acme.Widget.1.2.3.nupkg     # before
  Acme.Widget.nuspec
  lib/
  lib/thing.dll
  readme.txt

Opened with .NET's OPC reader — which is what strict feeds use — that package resolves to zero parts and has no manifest relationship at all:

--- before
    OPC open           : OK (0 parts)
    manifest rel       : MISSING
    core-properties rel: MISSING
    package creator    :

Change

See BuildPackageWithContents and buildArchive

Verification

Structure now matches dotnet pack exactly.

dotnet pack                              octopus package nuget create
  _rels/.rels                              _rels/.rels
  Ref.Widget.nuspec                        Acme.Widget.nuspec
  lib/net8.0/ref.dll                       lib/thing.dll
  [Content_Types].xml                      [Content_Types].xml
  package/services/.../<hash>.psmdcp       package/services/.../<hash>.psmdcp

Validated with a real .NET OPC reader (System.IO.Packaging + NuGet.Packaging), before and after:

--- before                             --- after
    OPC open           : OK (0 parts)      OPC open           : OK (6 parts)
    manifest rel       : MISSING           manifest rel       : /Acme.Widget.nuspec
    core-properties rel: MISSING           core-properties rel: /package/services/.../<hash>.psmdcp
    package creator    :                   package creator    : Acme

🤖 Generated with Claude Code

NickJosevski and others added 2 commits August 4, 2026 18:51
The command wrote the nuspec and the matched files into a zip and named
it .nupkg. A .nupkg is an Open Packaging Conventions container, so the
result was missing [Content_Types].xml, _rels/.rels and the core
properties part. Opened with a real OPC reader the package resolves to
zero parts and no manifest relationship, which is why feeds such as
Cloudsmith and Artifactory reject or fail to list it.

Generate the three OPC parts alongside the nuspec. Content types are
derived from the extensions actually present, with an Override for any
part that has no extension, and the generated part and relationship
names are derived from the package id and version so repacking the same
inputs is reproducible.

Directory records are also omitted from .nupkg archives, since OPC part
names may not end in "/". `package zip create` is untouched and still
includes them.

Fixes #477

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Matches how the repo names a variant that takes extra behaviour:
DeleteWithConfirmation, SelectMapWithNew, MapCollectionWithLookups.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@NickJosevski
NickJosevski marked this pull request as ready for review August 5, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

octopus package nuget create generates invalid NuGet packages

1 participant