Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / .NET

Nuget's Get-Package - See Entire Package Name

5.00/5 (2 votes)
2 Oct 2017CPOL1 min read 10.6K  
Nuget's Get-Package command truncates some long package names. This is about how to avoid that.

Introduction

Normally, when NuGet displays a list of packages, the Id column, i.e., the package name column is quite a conservative fixed width, and more often than not, at least one package name, if not all, is or are truncated. With the plethora of packages starting with the same prefixes, it is foreseeable that one day, in the output of some Get-Package, the visible parts of the package names are all the same!

Background

I know next to nothing about PowerShell output formatting, like whether the current Get-Package formatting is a NuGet or a PowerShell product. It doesn't really matter because I have found a solution to the problem with just PowerShell.

Using the Code

A basic knowing your way around Nuget's Package Manager Console (although it's more like everything's console) is assumed, but no extra technical knowledge required.

To show the full length of the Id (package name) column, use this command:

Get-Package | ft -AutoSize

This pipes the output of Get-Package, a PowerShell CmdLet written for Nuget, to ft, an alias for the native Format-Table cmdlet. This cmdlet lives up to its name and offers various table formatting features. The only function we should worry about for package names is the -AutoSize option, which does what it says and tries to display the max of each column.

If you use options with Get-Package, like -ProjectName, you still use them as normal, just after the Get-Package but before the pipe to Format-Table.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)