dotnet-consolidate icon indicating copy to clipboard operation
dotnet-consolidate copied to clipboard

Export json to be machine readable

Open vbjay opened this issue 6 months ago • 18 comments

Will export json report instead of tables to make output parsable. This will allow scripting to be done against output.
Fixes #58

Example

diff --git a/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectA/ProjectA.csproj b/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectA/ProjectA.csproj
index 8faa44b..f0aca33 100644
--- a/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectA/ProjectA.csproj
+++ b/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectA/ProjectA.csproj
@@ -5,5 +5,9 @@
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <Platforms>x64;x64</Platforms>
   </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="System.Text.Json" Version="7.0.1" />
+    <PackageReference Include="System.Numerics" Version="4.3.0" />
+  </ItemGroup>
 
 </Project>
diff --git a/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectB/ProjectB.csproj b/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectB/ProjectB.csproj
index d5fdeaa..1c1d7b2 100644
--- a/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectB/ProjectB.csproj
+++ b/src/DotNet.Consolidate.Tests/TestData/TestSolution/src/ProjectB/ProjectB.csproj
@@ -6,7 +6,8 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="System.Text.Json" Version="7.0.3" />
+    <PackageReference Include="System.Text.Json" Version="7.0.2" />
+    <PackageReference Include="System.Numerics" Version="4.0.1" />
   </ItemGroup>
 
 </Project>
diff --git a/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectA.Tests/ProjectA.Tests.csproj b/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectA.Tests/ProjectA.Tests.csproj
index 52e6553..1748bf3 100644
--- a/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectA.Tests/ProjectA.Tests.csproj
+++ b/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectA.Tests/ProjectA.Tests.csproj
@@ -3,5 +3,8 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
   </PropertyGroup>
-
+  
+  <ItemGroup>
+    <PackageReference Include="System.Text.Json" Version="7.0.3" />
+  </ItemGroup>
 </Project>
diff --git a/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectB.Tests/ProjectB.Tests.csproj b/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectB.Tests/ProjectB.Tests.csproj
index 52e6553..1bb5727 100644
--- a/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectB.Tests/ProjectB.Tests.csproj
+++ b/src/DotNet.Consolidate.Tests/TestData/TestSolution/tests/ProjectB.Tests/ProjectB.Tests.csproj
@@ -3,5 +3,8 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
   </PropertyGroup>
-
+  
+  <ItemGroup>
+    <PackageReference Include="System.Text.Json" Version="7.0.4" />
+  </ItemGroup>
 </Project>

$json = .\DotNet.Consolidate.exe -s "C:\git\dotnet-consolidate\src\DotNet.Consolidate.Tests\TestData\TestSolution\TestSolution.sln" -f Json

Formatted Output below

{
  "Solutions": [
    {
      "Solution": {
        "ProjectInfos": [
          {
            "Packages": [
              {
                "Id": "System.Text.Json",
                "Version": {
                  "OriginalValue": "7.0.1",
                  "NormalizedValue": "7.0.1"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "System.Numerics",
                "Version": {
                  "OriginalValue": "4.3.0",
                  "NormalizedValue": "4.3"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "CommandLineParser",
                "Version": {
                  "OriginalValue": "2.7.82",
                  "NormalizedValue": "2.7.82"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Serilog",
                "Version": {
                  "OriginalValue": "3.0.1",
                  "NormalizedValue": "3.0.1"
                },
                "PackageReferenceType": "Inherited"
              }
            ],
            "ProjectName": "ProjectA",
            "ProjectDirectory": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\src\\ProjectA"
          },
          {
            "Packages": [
              {
                "Id": "System.Text.Json",
                "Version": {
                  "OriginalValue": "7.0.2",
                  "NormalizedValue": "7.0.2"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "System.Numerics",
                "Version": {
                  "OriginalValue": "4.0.1",
                  "NormalizedValue": "4.0.1"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "CommandLineParser",
                "Version": {
                  "OriginalValue": "2.7.82",
                  "NormalizedValue": "2.7.82"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Serilog",
                "Version": {
                  "OriginalValue": "3.0.1",
                  "NormalizedValue": "3.0.1"
                },
                "PackageReferenceType": "Inherited"
              }
            ],
            "ProjectName": "ProjectB",
            "ProjectDirectory": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\src\\ProjectB"
          },
          {
            "Packages": [
              {
                "Id": "System.Text.Json",
                "Version": {
                  "OriginalValue": "7.0.3",
                  "NormalizedValue": "7.0.3"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "AutoFixture",
                "Version": {
                  "OriginalValue": "4.17.0",
                  "NormalizedValue": "4.17"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "FluentAssertions",
                "Version": {
                  "OriginalValue": "6.7.0",
                  "NormalizedValue": "6.7"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Microsoft.NET.Test.Sdk",
                "Version": {
                  "OriginalValue": "17.2.0",
                  "NormalizedValue": "17.2"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Moq",
                "Version": {
                  "OriginalValue": "4.18.1",
                  "NormalizedValue": "4.18.1"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "NUnit",
                "Version": {
                  "OriginalValue": "3.13.3",
                  "NormalizedValue": "3.13.3"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "NUnit3TestAdapter",
                "Version": {
                  "OriginalValue": "4.2.1",
                  "NormalizedValue": "4.2.1"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "coverlet.collector",
                "Version": {
                  "OriginalValue": "3.1.2",
                  "NormalizedValue": "3.1.2"
                },
                "PackageReferenceType": "Inherited"
              }
            ],
            "ProjectName": "ProjectA.Tests",
            "ProjectDirectory": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\tests\\ProjectA.Tests"
          },
          {
            "Packages": [
              {
                "Id": "System.Text.Json",
                "Version": {
                  "OriginalValue": "7.0.4",
                  "NormalizedValue": "7.0.4"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "AutoFixture",
                "Version": {
                  "OriginalValue": "4.17.0",
                  "NormalizedValue": "4.17"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "FluentAssertions",
                "Version": {
                  "OriginalValue": "6.7.0",
                  "NormalizedValue": "6.7"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Microsoft.NET.Test.Sdk",
                "Version": {
                  "OriginalValue": "17.2.0",
                  "NormalizedValue": "17.2"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "Moq",
                "Version": {
                  "OriginalValue": "4.18.1",
                  "NormalizedValue": "4.18.1"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "NUnit",
                "Version": {
                  "OriginalValue": "3.13.3",
                  "NormalizedValue": "3.13.3"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "NUnit3TestAdapter",
                "Version": {
                  "OriginalValue": "4.2.1",
                  "NormalizedValue": "4.2.1"
                },
                "PackageReferenceType": "Inherited"
              },
              {
                "Id": "coverlet.collector",
                "Version": {
                  "OriginalValue": "3.1.2",
                  "NormalizedValue": "3.1.2"
                },
                "PackageReferenceType": "Inherited"
              }
            ],
            "ProjectName": "ProjectB.Tests",
            "ProjectDirectory": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\tests\\ProjectB.Tests"
          }
        ],
        "DirectoryBuildPropsInfos": [
          {
            "Packages": [
              {
                "Id": "CommandLineParser",
                "Version": {
                  "OriginalValue": "2.7.82",
                  "NormalizedValue": "2.7.82"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "Serilog",
                "Version": {
                  "OriginalValue": "3.0.1",
                  "NormalizedValue": "3.0.1"
                },
                "PackageReferenceType": "Direct"
              }
            ],
            "FileName": "Directory.build.props",
            "DirectoryName": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution"
          },
          {
            "Packages": [
              {
                "Id": "AutoFixture",
                "Version": {
                  "OriginalValue": "4.17.0",
                  "NormalizedValue": "4.17"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "FluentAssertions",
                "Version": {
                  "OriginalValue": "6.7.0",
                  "NormalizedValue": "6.7"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "Microsoft.NET.Test.Sdk",
                "Version": {
                  "OriginalValue": "17.2.0",
                  "NormalizedValue": "17.2"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "Moq",
                "Version": {
                  "OriginalValue": "4.18.1",
                  "NormalizedValue": "4.18.1"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "NUnit",
                "Version": {
                  "OriginalValue": "3.13.3",
                  "NormalizedValue": "3.13.3"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "NUnit3TestAdapter",
                "Version": {
                  "OriginalValue": "4.2.1",
                  "NormalizedValue": "4.2.1"
                },
                "PackageReferenceType": "Direct"
              },
              {
                "Id": "coverlet.collector",
                "Version": {
                  "OriginalValue": "3.1.2",
                  "NormalizedValue": "3.1.2"
                },
                "PackageReferenceType": "Direct"
              }
            ],
            "FileName": "Directory.build.props",
            "DirectoryName": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\tests"
          }
        ],
        "SolutionFile": "C:\\git\\dotnet-consolidate\\src\\DotNet.Consolidate.Tests\\TestData\\TestSolution\\TestSolution.sln",
        "Solution": {
          "Header": [
            "",
            "Microsoft Visual Studio Solution File, Format Version 12.00",
            "# Visual Studio Version 17",
            "VisualStudioVersion = 17.6.33723.286",
            "MinimumVisualStudioVersion = 10.0.40219.1"
          ],
          "Global": [
            {
              "Name": "SolutionConfigurationPlatforms",
              "Type": "PreSolution",
              "Entries": {
                "Debug|x64": "Debug|x64",
                "Release|x64": "Release|x64"
              }
            },
            {
              "Name": "ProjectConfigurationPlatforms",
              "Type": "PostSolution",
              "Entries": {
                "{B2641D3B-1DE4-462D-BBBF-6874EFC3B7D0}.Debug|x64.ActiveCfg": "Debug|Any CPU",
                "{B2641D3B-1DE4-462D-BBBF-6874EFC3B7D0}.Debug|x64.Build.0": "Debug|Any CPU",
                "{B2641D3B-1DE4-462D-BBBF-6874EFC3B7D0}.Release|x64.ActiveCfg": "Release|Any CPU",
                "{B2641D3B-1DE4-462D-BBBF-6874EFC3B7D0}.Release|x64.Build.0": "Release|Any CPU",
                "{76DB371A-4871-417B-8CD5-38F4250050BF}.Debug|x64.ActiveCfg": "Debug|Any CPU",
                "{76DB371A-4871-417B-8CD5-38F4250050BF}.Debug|x64.Build.0": "Debug|Any CPU",
                "{76DB371A-4871-417B-8CD5-38F4250050BF}.Release|x64.ActiveCfg": "Release|Any CPU",
                "{76DB371A-4871-417B-8CD5-38F4250050BF}.Release|x64.Build.0": "Release|Any CPU",
                "{01777C80-CDE9-49C7-8FAD-590CAF9E8E23}.Debug|x64.ActiveCfg": "Debug|Any CPU",
                "{01777C80-CDE9-49C7-8FAD-590CAF9E8E23}.Debug|x64.Build.0": "Debug|Any CPU",
                "{01777C80-CDE9-49C7-8FAD-590CAF9E8E23}.Release|x64.ActiveCfg": "Release|Any CPU",
                "{01777C80-CDE9-49C7-8FAD-590CAF9E8E23}.Release|x64.Build.0": "Release|Any CPU",
                "{FA79411B-61D5-40E5-8E5C-B832E5E57BBD}.Debug|x64.ActiveCfg": "Debug|Any CPU",
                "{FA79411B-61D5-40E5-8E5C-B832E5E57BBD}.Debug|x64.Build.0": "Debug|Any CPU",
                "{FA79411B-61D5-40E5-8E5C-B832E5E57BBD}.Release|x64.ActiveCfg": "Release|Any CPU",
                "{FA79411B-61D5-40E5-8E5C-B832E5E57BBD}.Release|x64.Build.0": "Release|Any CPU"
              }
            },
            {
              "Name": "SolutionProperties",
              "Type": "PreSolution",
              "Entries": {
                "HideSolutionNode": "FALSE"
              }
            },
            {
              "Name": "NestedProjects",
              "Type": "PreSolution",
              "Entries": {
                "{B2641D3B-1DE4-462D-BBBF-6874EFC3B7D0}": "{91927A48-FE66-4083-8F03-EEAFA974C86C}",
                "{76DB371A-4871-417B-8CD5-38F4250050BF}": "{91927A48-FE66-4083-8F03-EEAFA974C86C}",
                "{01777C80-CDE9-49C7-8FAD-590CAF9E8E23}": "{5CD86CD0-0B02-47B4-9633-5C65875733FC}",
                "{FA79411B-61D5-40E5-8E5C-B832E5E57BBD}": "{5CD86CD0-0B02-47B4-9633-5C65875733FC}"
              }
            },
            {
              "Name": "ExtensibilityGlobals",
              "Type": "PostSolution",
              "Entries": {
                "SolutionGuid": "{40DE902E-DB50-4D7C-A519-E6DC61D0059A}"
              }
            }
          ],
          "Projects": [
            {
              "TypeGuid": "2150e333-8fdc-42a3-9474-1a3956d46de8",
              "Name": "src",
              "Path": "src",
              "Guid": "91927a48-fe66-4083-8f03-eeafa974c86c",
              "ProjectSection": null
            },
            {
              "TypeGuid": "2150e333-8fdc-42a3-9474-1a3956d46de8",
              "Name": "tests",
              "Path": "tests",
              "Guid": "5cd86cd0-0b02-47b4-9633-5c65875733fc",
              "ProjectSection": {
                "Name": "SolutionItems",
                "Type": "PreProject",
                "Entries": {
                  "tests\\Directory.build.props": "tests\\Directory.build.props"
                }
              }
            },
            {
              "TypeGuid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
              "Name": "ProjectA",
              "Path": "src\\ProjectA\\ProjectA.csproj",
              "Guid": "b2641d3b-1de4-462d-bbbf-6874efc3b7d0",
              "ProjectSection": null
            },
            {
              "TypeGuid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
              "Name": "ProjectB",
              "Path": "src\\ProjectB\\ProjectB.csproj",
              "Guid": "76db371a-4871-417b-8cd5-38f4250050bf",
              "ProjectSection": null
            },
            {
              "TypeGuid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
              "Name": "ProjectA.Tests",
              "Path": "tests\\ProjectA.Tests\\ProjectA.Tests.csproj",
              "Guid": "01777c80-cde9-49c7-8fad-590caf9e8e23",
              "ProjectSection": null
            },
            {
              "TypeGuid": "9a19103f-16f7-4668-be54-9a1e7a4f7556",
              "Name": "ProjectB.Tests",
              "Path": "tests\\ProjectB.Tests\\ProjectB.Tests.csproj",
              "Guid": "fa79411b-61d5-40e5-8e5c-b832e5e57bbd",
              "ProjectSection": null
            },
            {
              "TypeGuid": "2150e333-8fdc-42a3-9474-1a3956d46de8",
              "Name": "Solution Items",
              "Path": "Solution Items",
              "Guid": "cf9fa02d-aa0b-4a3a-8cf0-f1124fa43b43",
              "ProjectSection": {
                "Name": "SolutionItems",
                "Type": "PreProject",
                "Entries": {
                  "Directory.build.props": "Directory.build.props"
                }
              }
            }
          ]
        },
        "IsParsedWithoutIssues": true
      },
      "NonConsolidatedPackages": [
        {
          "ContainsDifferentPackagesVersions": true,
          "NuGetPackageId": "System.Text.Json",
          "PackageVersions": [
            {
              "NuGetPackageVersion": {
                "OriginalValue": "7.0.1",
                "NormalizedValue": "7.0.1"
              },
              "ProjectName": "ProjectA"
            },
            {
              "NuGetPackageVersion": {
                "OriginalValue": "7.0.2",
                "NormalizedValue": "7.0.2"
              },
              "ProjectName": "ProjectB"
            },
            {
              "NuGetPackageVersion": {
                "OriginalValue": "7.0.3",
                "NormalizedValue": "7.0.3"
              },
              "ProjectName": "ProjectA.Tests"
            },
            {
              "NuGetPackageVersion": {
                "OriginalValue": "7.0.4",
                "NormalizedValue": "7.0.4"
              },
              "ProjectName": "ProjectB.Tests"
            }
          ]
        },
        {
          "ContainsDifferentPackagesVersions": true,
          "NuGetPackageId": "System.Numerics",
          "PackageVersions": [
            {
              "NuGetPackageVersion": {
                "OriginalValue": "4.3.0",
                "NormalizedValue": "4.3"
              },
              "ProjectName": "ProjectA"
            },
            {
              "NuGetPackageVersion": {
                "OriginalValue": "4.0.1",
                "NormalizedValue": "4.0.1"
              },
              "ProjectName": "ProjectB"
            }
          ]
        }
      ]
    }
  ]
}


Push-Location "$PSScriptRoot\TestSolution\"
$json = dotnet consolidate -f Json
$converted = $json | ConvertFrom-Json
Pop-Location

# $json
# $converted

$notConsolidated = $converted.Solutions | % {
    $sln = $_.Solution
    $_.NonConsolidatedPackages | % {
        $pck = [PSCustomObject]@{
            Package  = $_.NuGetPackageId
            Versions = (($_.PackageVersions  | sort -Property NuGetPackageVersion -Descending ).NuGetPackageVersion.OriginalValue) | % { [Version]::Parse($_) }
            Solution = $sln
        }
        
        $pck
    } | % {
        $pck = $_
        $pck | Add-Member -MemberType NoteProperty -Name LatestVersion -Value ($pck.Versions | sort -Descending)[0]
        
        $pck
    }
}
    
$notConsolidated | fl




Package       : System.Text.Json
Versions      : {7.0.3, 7.0.4, 7.0.1, 7.0.2}
Solution      : @{ProjectInfos=System.Object[]; DirectoryBuildPropsInfos=System.Object[]; SolutionFile=C:\git\dotnet-co
                nsolidate\src\DotNet.Consolidate.Tests\TestData\TestSolution\TestSolution.sln; Solution=; 
                IsParsedWithoutIssues=True}
LatestVersion : 7.0.4

Package       : System.Numerics
Versions      : {4.0.1, 4.3.0}
Solution      : @{ProjectInfos=System.Object[]; DirectoryBuildPropsInfos=System.Object[]; SolutionFile=C:\git\dotnet-co
                nsolidate\src\DotNet.Consolidate.Tests\TestData\TestSolution\TestSolution.sln; Solution=; 
                IsParsedWithoutIssues=True}
LatestVersion : 4.3.0




vbjay avatar Dec 26 '23 15:12 vbjay

@olsh I am going to use this in some projects where I am applying Kentico hotfixes to websites and want to automate the fixing of nuget packages.

function Update-Package {
    param(
        [Parameter(Mandatory = $true)]
        [string]
        $package,
        [Parameter(Mandatory = $true)]
        [string[]]
        $version
    )

    foreach ($sln in $slns) {
        Write-Host "Processing $sln"
        $cmdArgs = "update", "-Id", $($package), "-version", $($version), "-configfile", "$PSScriptRoot\..\src\nuget.config", "$sln"
        & "$PSScriptRoot\..\tools\nuget.exe" $cmdArgs
    }
    $projs = Get-ChildItem -Filter *.csproj -Recurse | % { $_.FullName }
    $projs | ? { $(Select-String -Path $_ -Pattern "PackageReference.*$($package.Replace('\.', '\\.'))" ).Matches.Length -gt 0 } | % {
        dotnet add "$_" package $($package) --version $($version)

    }
}

function Consolidate-Packages {
    $slns | % {
        # $json = dotnet consolidate -s ".\src\CMS.sln" -j
        $json = dotnet consolidate -s "$_" -j
        $converted = $json | ConvertFrom-Json
        $notConsolidated = $converted | % {
            $pck = [PSCustomObject]@{
                Package  = $_.NuGetPackageId
                Versions = (($_.PackageVersions  | sort -Property NuGetPackageVersion -Descending ).NuGetPackageVersion.OriginalValue) | % { [Version]::Parse($_) }
            }
            $pck
        } | % {
            $pck = $_
            $pck | Add-Member -MemberType NoteProperty -Name LatestVersion -Value ($pck.Versions | sort -Descending)[0]

            $pck
        }
        if ($notConsolidated.Count -gt 0) {
            $notConsolidated | % {
                Update-Package -package $_.Package -version $_.LatestVersion
            }

        }
    }
}

  @("Kentico.Xperience.Libraries", "Kentico.Xperience.AspNetCore.WebApp") | % {
            Update-Package -package $_ -version $hotfixVersion
        }
        Consolidate-Packages

vbjay avatar Dec 30 '23 17:12 vbjay

@olsh I have just about completed my Hotfix work for my website projects. I really need this to be reviewed and either issues with it mentioned or merged and a release made. This is now becoming a blocker on my work. Thanks for a great tool.

vbjay avatar Jan 09 '24 14:01 vbjay

Thank you for the contribution. 👍🏻

olsh avatar Jan 09 '24 16:01 olsh

Also, it would be nice to update the readme file.

Will Do

vbjay avatar Jan 09 '24 22:01 vbjay

Please fix the unit tests.

Temporary testing commit just showing my debugging setup. Will drop once I rebase.

vbjay avatar Jan 10 '24 06:01 vbjay

I realized If you passed in multiple solutions the json was going to be weird. Close to fixing that part. Just making sure it acts right.

vbjay avatar Jan 10 '24 06:01 vbjay

I realized If you passed in multiple solutions the json was going to be weird. Close to fixing that part. Just making sure it acts right.

Good point, I didn't think about that.

olsh avatar Jan 10 '24 06:01 olsh

Quick question...

I am planning on building an object that represents across all solutions here are your non consolidated packages deduped and versions deduped. At the same time I will expose the solution detail and each solution/Package set.

Something like

{
AllNonConsolidatedPackages:[...], BySolution:
    [
        {
        Solution:{...}, 
        NonConsolidatedPackages:[...]
        }
    ]
}

That way the user of the json can decide if they want cross solutions distinct values or per solution data.

So my question is do you want the output to be controlled so it always generates this kind of format or do you want an option like IncludePerSolutionDetails to control what is generated?

vbjay avatar Jan 10 '24 06:01 vbjay

Quick question...

I am planning on building an object that represents across all solutions here are your non consolidated packages deduped and versions deduped. At the same time I will expose the solution detail and each solution/Package set.

Something like

{
AllNonConsolidatedPackages:[...], BySolution:
    [
        {
        Solution:{...}, 
        NonConsolidatedPackages:[...]
        }
    ]
}

That way the user of the json can decide if they want cross solutions distinct values or per solution data.

So my question is do you want the output to be controlled so it always generates this kind of format or do you want an option like IncludePerSolutionDetails to control.id that is generated?

I think the AllNonConsolidatedPackages is not universal, let's use BySolution approach. If a user wants to select distinct packages, he always can do this himself with PS or other tool.

olsh avatar Jan 10 '24 07:01 olsh

Quick question...

I am planning on building an object that represents across all solutions here are your non consolidated packages deduped and versions deduped. At the same time I will expose the solution detail and each solution/Package set.

Something like

{
AllNonConsolidatedPackages:[...], BySolution:
    [
        {
        Solution:{...}, 
        NonConsolidatedPackages:[...]
        }
    ]
}

That way the user of the json can decide if they want cross solutions distinct values or per solution data.

So my question is do you want the output to be controlled so it always generates this kind of format or do you want an option like IncludePerSolutionDetails to control.id that is generated?

I think the AllNonConsolidatedPackages is not universal, let's use BySolution approach. If a user wants to select distinct packages, he always can do this himself with PS or other tool.

Ok. I'll take your review stuff and get this finished later on today. I'll ping for a review once done and then after you say good. I'll rebase to squash down.

vbjay avatar Jan 10 '24 07:01 vbjay

Ok @olsh think I got it ready. Let me know what you think about this.

vbjay avatar Jan 12 '24 00:01 vbjay

Fixed

  • Encoding mismatch if text output
  • iMissed change in one spot that prevented output of one line in text output Adding readme changes next but looks good.

vbjay avatar Jan 13 '24 12:01 vbjay

Also count to be distinct by package id.

vbjay avatar Jan 13 '24 12:01 vbjay

Fixed BOM issue with text output and updated readme. @olsh This should be it. I validated text output was good with both formats.

vbjay avatar Jan 13 '24 13:01 vbjay

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

4 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarcloud[bot] avatar Jan 13 '24 22:01 sonarcloud[bot]

Pushed fixes for some of sonar cloud issues but for example the count. https://stackoverflow.com/questions/305092/which-method-performs-better-any-vs-count-0 Get's fun determining. I guess since the source object is a List which is an ICollection I can switch to Count >0 way if you want. Let me know if you want to fix or ignore the rest. See https://github.com/dotnet/runtime/blob/d14587922635ecf583733051106cc147f6173e06/src/libraries/System.Linq/src/System/Linq/Count.cs#L95 which is called in Any.

vbjay avatar Jan 13 '24 23:01 vbjay

🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔

vbjay avatar Jan 26 '24 07:01 vbjay

Yes, I remember about the PR. But sadly, I don't have time for OS projects. I'll take a look later.

olsh avatar Jan 26 '24 11:01 olsh