Click here to Skip to main content
15,860,972 members
Articles / .NET
Tip/Trick

Nuget's Get-Package - See Entire Package Name

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
2 Oct 2017CPOL1 min read 9.9K   1
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)


Written By
Founder Erisia Web Development
South Africa South Africa
I am a software developer in Johannesburg, South Africa. I specialise in C# and ASP.NET MVC, with SQL Server, with special fondness for MVC and jQuery. I have been in this business for about eighteen years, and am currently trying to master Angular 4 and .NET Core, and somehow find a way to strengthen my creative faculties.
- Follow me on Twitter at @bradykelly

Comments and Discussions

 
GeneralMy vote of 5 Pin
Mark Shyn11-Aug-21 16:43
Mark Shyn11-Aug-21 16:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.