NuGet / NuGet/Home

Zip unix file permissions are not restored properly when importing nuget package

Open
#13,402 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Functionality:Restore Platform:Xplat Priority:3 Type:Bug
Dominant language
HTML
Stars
1.6k
Forks
276
Avg merge
6d 1h
Merged PRs (30d)
1

Description

NuGet Product Used

dotnet.exe

Product Version

8.0.203

Worked before?

it's been broken forever as far as I know

Impact

It's more difficult to complete my work

Repro Steps & Context

Nuget does not properly restore the unix file permissions encoded in the .nupkg zip file, which is particularly annoying when packaging executables to be imported into a .NET application for redistribution. I maintain an OpenSSH distribution for which the 'ssh' executable is included in the Devolutions.OpenSSH.Client nuget package we import into Remote Desktop Manager (.NET application) for Windows, macOS and Linux. Since nuget does not retain the unix file permissions properly when imported, we have to manually fix the file permissions locally with chmod commands. In the past, we've wasted a lot of time writing special .targets files that would call chmod commands, now we've switched to doing it in the CI environment. Either way, it's very annoying that nuget is currently not capable of just packaging files that will properly retain the correct unix file permissions when imported, forcing us to resort to less-than-desirable solutions.

To reproduce this issue, simply import Devolutions.OpenSSH.Client versions 9.5.0.1 from nuget.org, and look at the imported file permissions on the 'ssh' executables in the local nuget package cache:

GJSQLByW4AAL4f5

Now download the raw .nupkg file, change the extension to .zip and unzip it with the 'unzip' command on Linux, or even inspect its contents with 7-Zip or NanaZip on Windows without extracting it. All other zip tools I've tried correctly decode the zip file permissions on the 'ssh' executables contained within the .nupkg file, and restore them properly when unzipping on a non-Windows (Linux, macOS) file system.

There are various related issues (main issue) but they're not clearly scoped to zip file permissions when importing packages, and reading them, one could think it's an issue that's been fixed years ago when it clearly hasn't been fixed, and probably has never worked properly. Following a discussion on twitter regarding this problem, please do not mark this one as duplicate, because it isn't. Let's scope this problem correctly this time, and get it fixed.

While researching the root cause of the problem, this pull request seemed relevant, along with parts of NuGetExtractionFileIO.cs here and here.

Additionally, the problem has been discussed on twitter here as well, with additional context.

Verbose Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NuGetExtractionFileIO.cs at the referenced lines and review NuGet.Client pull request 1346 for the extraction behavior. Reproduce with Devolutions.OpenSSH.Client 9.5.0.1, comparing the permissions from the raw .nupkg with the extracted files on a Unix system. Done means Unix file permissions from the package are restored during import.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.