Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget, compare installed vs latest version

Can I get a list like this from the Nuget console:

Id          Installed Version           Latest Version  
----        -----------------           ----------------  
NHibernate  3.3.0.4000                  3.3.3.4001

And even better, for all the projects in the solution?

Ideas?

like image 559
Erik Sundström Avatar asked Feb 18 '14 09:02

Erik Sundström


3 Answers

got exception 'Item has already been added. Key in dictionary'. replaced $updates.Add($.Id, $.Version) by [Array]$updates[$.Id] += $.Version*

$updates = @{}; Get-Package -Updates | foreach { [Array]$updates[$_.Id] += $_.Version }; Get-Package | foreach { New-Object Object | Add-Member NoteProperty Name $_.Id -PassThru | Add-Member NoteProperty 'Installed Version' $_.Version -PassThru | Add-Member NoteProperty 'Latest Version' $updates.Get_Item($_.Id) -PassThru }

$updates = @{}; Get-Package -Updates | foreach {[Array]$updates[$_.Id] += $_.Version }; $toReview = Get-Package | foreach { New-Object Object | Add-Member NoteProperty Name $_.Id -PassThru | Add-Member NoteProperty 'Installed Version' $_.Version -PassThru | Add-Member NoteProperty 'Latest Version' $updates.Get_Item($_.Id) -PassThru } | sort -Property 'Name' -Unique | Out-File "$($dte.Solution.FileName).nuget.txt"
like image 89
Igor Kocherga Avatar answered Nov 07 '22 00:11

Igor Kocherga


You can paste this all as one line in the Package Manager Console:

$updates = @{}; Get-Package -Updates | foreach { $updates.Add($_.Id, $_.Version) }; Get-Package | foreach { New-Object Object | Add-Member NoteProperty Name $_.Id -PassThru | Add-Member NoteProperty 'Installed Version' $_.Version -PassThru | Add-Member NoteProperty 'Latest Version' $updates.Get_Item($_.Id) -PassThru }

This will give you results like:

Name                                       Installed Version  Latest Version
----                                       -----------------  --------------
Antlr                                      3.4.1.9004         3.5.0.2       
Autofac                                    3.2.0              3.3.0         
Autofac.Mvc5                               3.2.0                            
bootstrap                                  3.0.0              3.1.0         
EntityFramework                            6.0.0              6.0.2         
jQuery                                     1.10.2             2.1.0         
jQuery.Validation                          1.11.1                           
Microsoft.AspNet.Identity.Core             1.0.0                            
Microsoft.AspNet.Identity.EntityFramework  1.0.0                            
Microsoft.AspNet.Identity.Owin             1.0.0                            
Microsoft.AspNet.Mvc                       5.1.0              5.1.1         
Microsoft.AspNet.Razor                     3.1.0              3.1.1         
Microsoft.AspNet.Web.Optimization          1.1.1              1.1.2         
Microsoft.AspNet.WebApi                    5.0.0              5.1.1         
Microsoft.AspNet.WebApi.Client             5.0.0              5.1.1         
Microsoft.AspNet.WebApi.Core               5.0.0              5.1.1         
Microsoft.AspNet.WebApi.WebHost            5.0.0              5.1.1         
Microsoft.AspNet.WebPages                  3.1.0              3.1.1         
Microsoft.jQuery.Unobtrusive.Validation    3.0.0              3.1.1         
Microsoft.Owin                             2.0.0              2.1.0         
Microsoft.Owin.Host.SystemWeb              2.0.0              2.1.0         
Microsoft.Owin.Security                    2.0.0              2.1.0         
Microsoft.Owin.Security.Cookies            2.0.0              2.1.0         
Microsoft.Owin.Security.Facebook           2.0.0              2.1.0         
Microsoft.Owin.Security.Google             2.0.0              2.1.0         
Microsoft.Owin.Security.MicrosoftAccount   2.0.0              2.1.0         
Microsoft.Owin.Security.OAuth              2.0.0              2.1.0         
Microsoft.Owin.Security.Twitter            2.0.0              2.1.0         
Microsoft.Web.Infrastructure               1.0.0.0                          
Modernizr                                  2.6.2              2.7.1         
Newtonsoft.Json                            5.0.6              6.0.1         
Owin                                       1.0                              
RavenDB.Client                             2.5.2750                         
Respond                                    1.2.0              1.3.0         
WebGrease                                  1.5.2              1.6.0         
like image 44
Kiliman Avatar answered Nov 06 '22 22:11

Kiliman


I modified the script slightly to save the results to a text file in the solution folder called [solution filename].nuget.txt. Here's the script:

$updates = @{}; Get-Package -Updates | foreach { $updates.Add($_.Id, $_.Version) }; $toReview = Get-Package | foreach { New-Object Object | Add-Member NoteProperty Name $_.Id -PassThru | Add-Member NoteProperty 'Installed Version' $_.Version -PassThru | Add-Member NoteProperty 'Latest Version' $updates.Get_Item($_.Id) -PassThru } | sort -Property 'Name' -Unique | Out-File "$($dte.Solution.FileName).nuget.txt"
like image 34
Derek Price Avatar answered Nov 06 '22 23:11

Derek Price