Resolving Publish-PSArtifactUtility : Failed to generate the compressed file for script ‘C:\Program Files\dotnet\dotnet.exe failed to pack: error

Be the first to vote!

Since we had announced the retirement of the TechNet gallery last year, I’ve been slowly moving my scripts to the PowerShell gallery.  I haven’t posted any new scripts in a couple of months and wrote a new one today.  Uploading a script to the PowerShell Gallery typically requires using the Publish-Script cmdlet in conjunction with an API key.

And received this delightfully cryptic error:

Publish-PSArtifactUtility : Failed to generate the compressed file for script ‘C:\Program Files\dotnet\dotnet.exe failed to pack: error
‘.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.4.1\PSModule.psm1:11336 char:17
+ … Publish-PSArtifactUtility @PublishPSArtifactUtility_Param …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : FailedToCreateCompressedScript,Publish-PSArtifactUtility

I figured since I hadn’t done it in a while, maybe something was wrong with PowerShellGet, so I ran Update-Module PowerShellGet.  Same result.

The ultimate fix was equally as cryptic as the error message. From a new elevated PowerShell prompt, run the following command:

Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe"

From there, you should be able to run Publish-Script successfully.

Cheers!

 

Published by Aaron Guilmette

Helping companies conquer inferior technology since 1997. I spend my time developing and implementing technology solutions so people can spend less time with technology. Specialties: Active Directory and Exchange consulting and deployment, Virtualization, Disaster Recovery, Office 365, datacenter migration/consolidation, cheese. View all posts by Aaron Guilmette

Reader Comments

  1. Howdy,
    Thank you for sharing your knowledge during the past several years. I cant find my copy of idfix for public folders. Would you mind posting it to powershell gallery?
    Thanks again!
    Drew

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version