chocolatey / chocolatey/choco

Install-ChocolateyZipPackage manifest file name does not relate to unzipped file

Open
#2,104 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### What You Are Seeing?

I'm testing making a package (`choco new bob`) which unzips an embedded 7z into some location.

```ps1
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'abc.7z'
$unzipLocation = '{0}\MyTools' -f $Env:SystemDrive

$packageArgs = @{
packageName = $env:ChocolateyPackageName
file = $fileLocation
unzipLocation = $unzipLocation
}

Install-ChocolateyZipPackage @packageArgs
```

In *C:\ProgramData\chocolatey\lib\bob* there's now a file called *bobInstall.zip.txt* which contains paths to the unzipped contents.

In order to remove the unzipped contents, the uninstall script has to state:

```ps1
Uninstall-ChocolateyZipPackage $packageName 'bobInstall.zip'
```

This shows the original archive name **has nothing to do** with the uninstall's ZipFileName parameter.

### What is Expected?

I expect ZipFileName is the basename of the corresponding archive, unzipped during installation:

```ps1
Uninstall-ChocolateyZipPackage $packageName 'abc.7z'
```

This makes more sense to me.

Besides, it would allow unzipping multiple archives during installations. I haven't tested it, but right now I suppose unzipping multiple archives would end up with a lone manifest file with paths of the last archive only. (Agreeing that archive basenames must differ)

---

Another solution: add a parameter to `Install-ChocolateyZipPackage` to specify the ZipFileName that will be used with `Uninstall-ChocolateyZipPackage`:

```ps1
Install-ChocolateyZipPackage ... -ZipFileName 'foobar'
...
Uninstall-ChocolateyZipPackage $packageName 'foobar'
```

which would lead to a manifest *C:\ProgramData\chocolatey\lib\bob\foobar.txt*.

---

As a side note, maybe changing the manifest extension from *.txt* to *.zip-manifest* would make its purpose clearer. But I suppose this is a breaking change.

### How Did You Get This To Happen? (Steps to Reproduce)

Just use the above scripts.

Relates to https://github.com/chocolatey/choco/issues/1520#issuecomment-519545366

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementations of Install-ChocolateyZipPackage and Uninstall-ChocolateyZipPackage, then reproduce the abc.7z and bobInstall.zip behavior from the issue. Review how manifest names are selected and how multiple archives would be handled. Done means the agreed naming or parameter behavior is consistent between installation and uninstallation, with coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.