116
votes

Firstly, I do not want to use Visual Studio at all when dealing with the certain .nupkg files.

I know there is a tool called NuGet Package Explorer and this can export nupkg files to a certain file location using a gui, but I'm looking to setup a MSBuild task to run and unpack about 50 .nupkg files, using the command line.

My question is, is there a tool you can use via the command line which will unpack .nupkg files to a specified file location?

7

7 Answers

116
votes

You can also use the NuGet command line, by specifying a local host as part of an install. For example if your package is stored in the current directory

nuget install MyPackage -Source %cd% -OutputDirectory packages

will unpack it into the target directory.

162
votes

NuPKG files are just zip files, so anything that can process a zip file should be able to process a nupkg file, i.e, 7zip.

22
votes

Rename it to .zip, then extract it.

4
votes

did the same thing like this:

clear
cd PACKAGE_DIRECTORY

function Expand-ZIPFile($file, $destination)
{
    $shell = New-Object -ComObject Shell.Application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    {
        $shell.Namespace($destination).copyhere($item)
    }
}

Dir *.nupkg | rename-item -newname {  $_.name  -replace ".nupkg",".zip"  }

Expand-ZIPFile "Package.1.0.0.zip" “DESTINATION_PATH”
2
votes

This worked for me:

Rename-Item -Path A_Package.nupkg -NewName A_Package.zip

Expand-Archive -Path A_Package.zip -DestinationPath C:\Reference
1
votes

With PowerShell 5.1 (PackageManagement module)

Install-Package -Name MyPackage -Source (Get-Location).Path -Destination C:\outputdirectory
0
votes

I've expanded Zamarin.Essentials -version 1.6.1 with 7-zip and nuget package manager is not recognizing this package and I have source set to all. I've tried just my global package source alone too.

Also I've noticed package manager downloads multiple versions to same folder, was wondering if it's ok to put a version folder in a package and copy the package end into it?