Open or extract files nupkg with Powershell

12,634

Solution 1

You can use Expand-Archive (you have to rename the file, see Can I use PowerShell `Expand-Archive` upon a zip file with no extension)

Rename-Item "Newtonsoft.Json.12.0.1.nupkg" "Newtonsoft.Json.12.0.1.nupkg.zip"
Expand-Archive "Newtonsoft.Json.12.0.1.nupkg.zip"

Solution 2

I prefer to use nuget cli, because it also intstalls dependencies. All you need is nuget install yourpackage . It's really just a 5MB executable, you can even download it each time you need to get the package:

$nugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
Invoke-WebRequest -Uri $nugetUrl -OutFile ".\nuget.exe" 

.\nuget.exe install yourpackage
Share:
12,634
Виталий Новиков
Author by

Виталий Новиков

Updated on June 07, 2022

Comments

  • Виталий Новиков
    Виталий Новиков almost 2 years

    could you please help me? How I can open and extract files the "nupkg" package using the PowerShell. Thanks.

  • Shawn Melton
    Shawn Melton almost 3 years
    Package files are no different than a zip file, you can simply pass that file as-is and it will work the same. Expand-Archive -Path Newtonsoft.json.12.0.1.nupkg -Destination .