Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export json to be machine readable #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vbjay
Copy link

@vbjay vbjay commented Dec 26, 2023

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 vbjay force-pushed the feature/ExportJson branch from 766a3d0 to 1669754 Compare December 26, 2023 22:58
@vbjay vbjay changed the title WIP Export json to be machine readable Export json to be machine readable Dec 26, 2023
@vbjay vbjay force-pushed the feature/ExportJson branch from 1669754 to 369c5e4 Compare December 26, 2023 23:34
@vbjay
Copy link
Author

vbjay commented Dec 30, 2023

@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 vbjay force-pushed the feature/ExportJson branch from 369c5e4 to 6b71129 Compare January 2, 2024 23:43
@vbjay
Copy link
Author

vbjay commented Jan 9, 2024

@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.

Copy link
Owner

@olsh olsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

src/DotNet.Consolidate/Services/JsonLogger.cs Outdated Show resolved Hide resolved
src/DotNet.Consolidate/Models/Options.cs Outdated Show resolved Hide resolved
@olsh
Copy link
Owner

olsh commented Jan 9, 2024

Thank you for the contribution. 👍🏻

@vbjay
Copy link
Author

vbjay commented Jan 9, 2024

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

Will Do

@vbjay vbjay force-pushed the feature/ExportJson branch from 0b915e5 to 1c07323 Compare January 10, 2024 01:48
Copy link
Owner

@olsh olsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the unit tests.

src/DotNet.Consolidate/Models/OutputFormat.cs Outdated Show resolved Hide resolved
src/DotNet.Consolidate/Program.cs Outdated Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the file structure as is for now.
I don't see any benefits for a separate folder for each interface.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

src/DotNet.Consolidate/Services/JsonLogger.cs Outdated Show resolved Hide resolved
src/DotNet.Consolidate/Services/Loggers/JsonLogger.cs Outdated Show resolved Hide resolved
@vbjay
Copy link
Author

vbjay commented Jan 10, 2024

Please fix the unit tests.

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

@vbjay
Copy link
Author

vbjay commented Jan 10, 2024

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.

@olsh
Copy link
Owner

olsh commented Jan 10, 2024

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.

@vbjay
Copy link
Author

vbjay commented Jan 10, 2024

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?

@olsh
Copy link
Owner

olsh commented Jan 10, 2024

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.

@vbjay
Copy link
Author

vbjay commented Jan 10, 2024

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 vbjay force-pushed the feature/ExportJson branch 2 times, most recently from 358ed9c to 93762d5 Compare January 12, 2024 00:38
@vbjay
Copy link
Author

vbjay commented Jan 12, 2024

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

README.md Outdated Show resolved Hide resolved
@vbjay vbjay force-pushed the feature/ExportJson branch 3 times, most recently from 623e70d to 22876d1 Compare January 13, 2024 12:21
@vbjay
Copy link
Author

vbjay commented Jan 13, 2024

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 vbjay force-pushed the feature/ExportJson branch from 22876d1 to 5131e7d Compare January 13, 2024 12:33
@vbjay
Copy link
Author

vbjay commented Jan 13, 2024

Also count to be distinct by package id.

@vbjay vbjay force-pushed the feature/ExportJson branch from 5131e7d to e14690c Compare January 13, 2024 13:15
@vbjay vbjay force-pushed the feature/ExportJson branch from e14690c to 97cb75d Compare January 13, 2024 13:41
@vbjay
Copy link
Author

vbjay commented Jan 13, 2024

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

Copy link

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

@vbjay vbjay requested a review from olsh January 13, 2024 23:03
@vbjay
Copy link
Author

vbjay commented Jan 13, 2024

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
Copy link
Author

vbjay commented Jan 26, 2024

🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔

@olsh
Copy link
Owner

olsh commented Jan 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add switch to export json
3 participants