@@ -481,7 +481,8 @@ if (-not $noGui.IsPresent) {
481
481
}
482
482
483
483
function Get-Packages-Categories {
484
- $vmPackagesUrl = " https://www.myget.org/F/vm-packages/api/v2/Packages?$filter =IsLatestVersion%20eq%20true"
484
+ # MyGet API
485
+ $vmPackagesUrl = " https://www.myget.org/F/vm-packages/api/v2/Packages"
485
486
$vmPackagesFile = " ${Env: VM_COMMON_DIR} \vm-packages.xml"
486
487
$packagesByCategory = @ {}
487
488
do {
@@ -504,18 +505,26 @@ if (-not $noGui.IsPresent) {
504
505
505
506
# Extract package information from the XML
506
507
$vm_packages.SelectNodes (" //atom:entry" , $ns ) | ForEach-Object {
507
- $isLatestVersion = $_.SelectSingleNode (" m:properties/d:IsLatestVersion" , $ns ).InnerText
508
- if ($isLatestVersion -eq " true" ) {
509
- $packageName = $_.SelectSingleNode (" m:properties/d:Id" , $ns ).InnerText
508
+ $isLatestVersion = $_.SelectSingleNode (" m:properties/d:IsLatestVersion" , $ns ).InnerText
509
+ $category = $_.SelectSingleNode (" m:properties/d:Tags" , $ns ).InnerText
510
+
511
+ # we select only packages that have the latest version and contain a category
512
+ if ($isLatestVersion -eq " true" -and $category ) {
513
+ $packageName = $_.SelectSingleNode (" m:properties/d:Id" , $ns ).InnerText
510
514
$description = $_.SelectSingleNode (" m:properties/d:Description" , $ns ).InnerText
511
- $category = $_.SelectSingleNode (" m:properties/d:Tags" , $ns ).InnerText
515
+
516
+ if (-not ($packagesByCategory.ContainsKey ($category ))) {
517
+ # Initialize as an empty array
518
+ $packagesByCategory [$category ] = @ ()
519
+ }
520
+ # category should not be empty, this condition should be removed after all the old packages in nuget are removed
512
521
if ($category -ne " " ){
513
- if ( -not ( $packagesByCategory.ContainsKey ( $category ))) {
514
- $packagesByCategory [ $category ] = " "
515
- }
516
- $packagesByCategory [ $category ] += $packageName + " : " + $description + " `n "
522
+ $packagesByCategory [ $category ] += [ PSCustomObject ] @ {
523
+ PackageName = $packageName
524
+ PackageDescription = $description
525
+ }
517
526
}
518
- }
527
+ }
519
528
}
520
529
# Check if there is a next link in the XML and set the API URL to that link if it exists
521
530
$nextLink = $vm_packages.SelectSingleNode (" //atom:link[@rel='next']/@href" , $ns )
@@ -769,17 +778,7 @@ if (-not $noGui.IsPresent) {
769
778
param (
770
779
[string ]$category
771
780
)
772
- $packages = @ ()
773
- $lines = $packagesByCategory [$category ] -split " `n "
774
- foreach ($line in $lines ) {
775
- if ($line.Trim ()){
776
- $package , $description = $line -split ' \|'
777
- $packages += [PSCustomObject ]@ {
778
- PackageName = $package
779
- PackageDescription = $description
780
- }
781
- }
782
- }
781
+ $packages = $packagesByCategory [$category ]
783
782
return $packages
784
783
}
785
784
@@ -822,8 +821,8 @@ if (-not $noGui.IsPresent) {
822
821
$allPackagesButton.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
823
822
$allPackagesButton.Add_Click ({Select-AllPackages })
824
823
825
- $clearPackagesButton = New-Object system.Windows.Forms.Button
826
- $clearPackagesButton.text = " Select All"
824
+ $clearPackagesButton = New-Object system.Windows.Forms.Button
825
+ $clearPackagesButton.text = " Deselect All"
827
826
$clearPackagesButton.AutoSize = $true
828
827
$clearPackagesButton.location = New-Object System.Drawing.Point(210 , 750 )
829
828
$clearPackagesButton.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
@@ -877,9 +876,6 @@ if (-not $noGui.IsPresent) {
877
876
$checkBox.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 9 )
878
877
$checkBox.AutoSize = $true
879
878
$checkBox.Location = New-Object System.Drawing.Point(40 , $verticalPosition2 )
880
- if ($package.PackageName -in $packagesToInstall ){
881
- $checkBox.Checked = $true
882
- }
883
879
$checkBox.Name = " checkBox$numCheckBoxPackages "
884
880
$checkboxesPackages.Add ($checkBox )
885
881
$Panel_Categories.Controls.Add ($checkBox )
@@ -890,6 +886,10 @@ if (-not $noGui.IsPresent) {
890
886
$numCategories ++
891
887
}
892
888
889
+ # select packages that are in the config.xml
890
+ Set-InitialPackages
891
+
892
+
893
893
$FormCategories.controls.AddRange (@ ($categories_label , $Panel_Categories , $ContinueButton , $resetButton , $allPackagesButton , $cancelButton , $clearPackagesButton ))
894
894
$FormCategories.Add_Shown ({$FormCategories.Activate ()})
895
895
$resultCategories = $FormCategories.ShowDialog ()
0 commit comments