0

I'm trying to make a simple Boxstarter package that will install a few basics to new machines. Nothing special. I've created a new package as suggested in the docs (using the Boxstarter shell):

New-BoxstarterPackage -Name MyPackage -Description "I hope you enjoy MyPackage"

I've ended up stripping everything I had in tools/ChocolateyInstall.ps1 away and now it just contains:

Write-ChocolateySuccess "A success message"

I've then packaged this with:

Invoke-BoxstarterBuild MyPackage

I've then copied the resulting MyPackage.1.0.0.nupkg file to a fresh machine that has Boxstarter installed on it and run with:

Install-BoxstarterPackage -PackageName "C:\Temp\MyPackage.1.0.0.nupkg"

This is when I see errors:

ERROR: At C:\ProgramData\chocolatey\lib\tmp4CEB.tmp\tools\ChocolateyInstall.ps1:2 char:647
+ ... ∟MyPackage.nuspec ¢↑( ¶uPKNÄ0♀Ý#q‡¨ˆ;lP&#Ø! ...
+                                                                  ~
Missing closing ')' in expression.

At C:\ProgramData\chocolatey\lib\tmp4CEB.tmp\tools\ChocolateyInstall.ps1:2 char:651
+ ... Package.nuspec ¢↑( ¶uPKNÄ0♀Ý#q‡¨ˆ;lP&#Ø!ħ,× ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

If I open the version of ChocolateyInstall.ps1' from C:\ProgramData\Boxstarter\BuildPackages\tmp4CEB.tmp\tools`, it looks corrupt:

Screengrab of script file in notepad

It also looks like it contains some XML. What am I doing wrong?

Dan McCoy
  • 313
  • 2
  • 15
  • 1
    That file you show in your screenshot is in fact a .ZIP file (starts with `PK` followed by byte 05 and 06, which is the [FOURCC Code](https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes) for a .zip ) – Theo Apr 21 '22 at 12:26
  • Why does it have a .ps1 extension? And why is Boxstarter (or Chocolatey) trying to run it as though it's a script? – Dan McCoy Apr 21 '22 at 13:39

1 Answers1

1

I suspect that the issue that you are having here is that you are providing a path directly to a nupkg. As per the help documentation for the Install-BoxstarterPackagecmdlet, the PackageName property is expecting the following:

The names of one or more NuGet Packages to be installed or URIs or file paths pointing to a Chocolatey script. If using package names, the .nupkg file for the provided package names are searched in the following locations and order:

  • .\BuildPackages relative to the parent directory of the module file
  • The Chocolatey community feed
  • NugetSources in Boxstarter.config when the 'DelegateChocoSources' switch is used

Can you please try by passing in the package name, using one of the suggested sources for the package?

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60