├── src ├── Build │ ├── docs │ │ └── release-notes.txt │ ├── icon.png │ └── nuget.props ├── UpdatR │ ├── docs │ │ ├── README.md │ │ ├── release-notes.txt │ │ └── README.source.md │ ├── images │ │ └── icon.png │ ├── Properties │ │ └── launchSettings.json │ ├── UpdatR.csproj │ ├── Domain │ │ ├── Utils │ │ │ └── RetriveTargetFramework.cs │ │ ├── NuGetPackage.cs │ │ └── RootDir.cs │ ├── Summary.cs │ ├── Internals │ │ └── Result.cs │ └── Formatters │ │ └── TextFormatter.cs ├── dotnet-updatr │ ├── docs │ │ ├── README.md │ │ ├── release-notes.txt │ │ └── README.source.md │ ├── images │ │ └── icon.png │ ├── Properties │ │ └── launchSettings.json │ ├── dotnet-updatr.csproj │ └── Program.cs └── BuildingBlocks │ ├── Paths.cs │ ├── BuildingBlocks.projitems │ ├── BuildingBlocks.shproj │ └── NuGetLogger.cs ├── mdsource ├── footer.include.md ├── README.source.md ├── header.include.md ├── sdk-readme.include.md ├── cli-usage.txt └── cli-readme.include.md ├── tests ├── UpdatR.IntegrationTests │ ├── UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.-.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.--has.-.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Microsoft.-.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.--Microsoft.-.verified.txt │ ├── Resources │ │ ├── Packages │ │ │ ├── Dummy.0.0.1.nupkg │ │ │ ├── Dummy.0.0.2.nupkg │ │ │ ├── Dummy.Tool.0.0.1.nupkg │ │ │ ├── Dummy.Tool.0.0.2.nupkg │ │ │ ├── dotnet-ef.5.0.12.nupkg │ │ │ ├── dotnet-ef.5.0.16.nupkg │ │ │ ├── dotnet-ef.5.0.17.nupkg │ │ │ ├── dotnet-ef.5.0.5.nupkg │ │ │ ├── Has.Previews.0.0.1.nupkg │ │ │ ├── Has.Previews.0.0.2.nupkg │ │ │ ├── Has.Newer.Tfm.3.1.0.nupkg │ │ │ ├── Has.Newer.Tfm.5.0.0.nupkg │ │ │ ├── Has.Newer.Tfm.6.0.0.nupkg │ │ │ ├── Has.Previews.0.0.1-preview.nupkg │ │ │ ├── Has.Previews.0.0.3-preview.0.nupkg │ │ │ ├── Has.Previews.0.0.3-preview.1.nupkg │ │ │ ├── Microsoft.EntityFrameworkCore.5.0.12.nupkg │ │ │ └── Microsoft.EntityFrameworkCore.5.0.16.nupkg │ │ └── Templates │ │ │ ├── nuget.config │ │ │ ├── .config │ │ │ ├── dotnet-tools.json │ │ │ └── dotnet-tools2.json │ │ │ ├── Dummy.App.csproj │ │ │ └── Dummy.sln │ ├── Paths.cs │ ├── UpdaterTests.Given_UpToDate_When_UpdateDotnetConfig_Then_DoNothing_version=0.0.2.verified.txt │ ├── UpdaterTests.Given_DirectoryAsTarget_When_SingleDotnetConfig_Then_Update.verified.txt │ ├── UpdaterTests.Given_UpToDate_When_UpdateDotnetConfig_Then_DoNothing_version=0.0.1.verified.txt │ ├── UpdaterTests.Given_UpToDate_When_Update_Then_DoNothing_version=0.0.2.verified.txt │ ├── UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net5.0.verified.txt │ ├── Initialization.cs │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Microsoft.-.verified.txt │ ├── UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.--has.-.verified.txt │ ├── UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins_packages=Dummy.- Dummy.Tool.verified.txt │ ├── UpdaterTests.Given_DirectoryAsTarget_When_SingleCsproj_Then_Update.verified.txt │ ├── UpdaterTests.Given_UpToDate_When_Update_Then_DoNothing_version=0.0.1.verified.txt │ ├── UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net6.0.verified.txt │ ├── UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net7.0.verified.txt │ ├── UpdaterTests.Given_LatestPackageHasUnsupportedTfm_When_Update_Then_PickLatestSupportedTfm.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.-.verified.txt │ ├── UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.-.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.--Microsoft.-.verified.txt │ ├── UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.--Microsoft.-.verified.txt │ ├── UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins_packages=Dummy.- Microsoft.-.verified.txt │ ├── UpdatR.IntegrationTests.csproj │ ├── UpdaterTests.Given_UnknownPackageId_When_Updating_Then_DoNothing_hasNugetConfig=False.verified.txt │ ├── UpdaterTests.Given_UnknownPackageId_When_Updating_Then_DoNothing_hasNugetConfig=True.verified.txt │ ├── UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.1.verified.txt │ ├── UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.1-preview.verified.txt │ ├── UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.3-preview.0.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=.verified.txt │ ├── UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=.verified.txt │ ├── UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Microsoft.-.verified.txt │ ├── UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.--has.-.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-.config.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-.config-dotnet-tools.json.verified.txt │ ├── UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=.config.verified.txt │ ├── UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=.config-dotnet-tools.json.verified.txt │ ├── UpdaterTests.Given_Target_When_DryRun_Then_DoNothing.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=Dummy.sln.verified.txt │ ├── UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-Dummy.App.csproj.verified.txt │ ├── UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=..verified.txt │ ├── UpdaterTests.Given_OutdatedDotnetEf_When_UpdatingCsprojToNewer_Then_UpdateToCsprojVersion_path=..verified.txt │ ├── UpdaterTests.Given_MultiplePackagesInDotnetTools_When_OneOutdated_Then_UpdateThatOne_path=.config.verified.txt │ ├── UpdaterTests.Given_OutdatedDotnetEf_When_UpdatingCsprojToNewer_Then_UpdateToCsprojVersion_path=Dummy.sln.verified.txt │ ├── UpdaterTests.Given_MultiplePackagesInDotnetTools_When_OneOutdated_Then_UpdateThatOne_path=.config-dotnet-tools.json.verified.txt │ ├── UpdaterTests.Given_CsprojNotAddedToSln_When_TargetSln_Then_DoNothing_target=Dummy.sln.verified.txt │ ├── UpdaterTests.Given_CsprojNotAddedToSln_When_TargetSln_Then_DoNothing_target=.verified.txt │ └── FileCreationUtils.cs ├── UpdatR.UnitTests │ ├── Formatters │ │ ├── MarkdownFormatterTests.EmptyResults_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.NothingToReport_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.EmptyResults_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.KitchenSink_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.NothingToReport_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.TwoUpdatedPackage_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackage_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.EmptyResults_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.OneUnknownPackage_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackage_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.UnauthorizedSource_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackage_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.NothingToReport_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=GenerateTitle.verified.txt │ │ ├── MarkdownFormatterTests.OneUnknownPackage_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.UnauthorizedSource_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackage_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.OneUnknownPackage_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.UnauthorizedSource_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackage_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackage_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackage_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackage_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.DeprecatedPackage_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.TwoUpdatedPackage_method=GenerateDescription.verified.txt │ │ ├── MarkdownFormatterTests.TwoUpdatedPackage_method=Generate.verified.txt │ │ ├── MarkdownFormatterTests.KitchenSink_method=GenerateDescription.verified.txt │ │ └── MarkdownFormatterTests.KitchenSink_method=Generate.verified.txt │ ├── GlobalSuppressions.cs │ ├── UpdatR.UnitTests.csproj │ └── Domain │ │ └── NuGetPackageTests.cs ├── UpdatR.E2eTests │ ├── Dummy │ │ ├── Dummy.App │ │ │ ├── Program.cs │ │ │ └── Dummy.App.csproj │ │ ├── nuget.config │ │ └── Dummy.sln │ ├── UpdatR.E2eTests.csproj │ ├── TestOutputHelperTextWriterAdapter.cs │ └── LiveTests.cs └── DummyPackage │ ├── DummyPackage.csproj │ └── Build.cs ├── mdsnippets.json ├── tools └── Build │ ├── Properties │ └── launchSettings.json │ ├── .config │ └── dotnet-tools.json │ └── Build.csproj ├── docs └── UpdatR.SampleApp │ ├── UpdatR.SampleApp.csproj │ └── Program.cs ├── .github ├── workflows │ ├── update-docs.yml │ ├── push.yml │ ├── build.yml │ ├── release.yml │ ├── post-release.yml │ └── update.yml └── FUNDING.yml ├── Directory.Build.props ├── LICENSE ├── .editorconfig ├── README.md └── .gitignore /src/Build/docs/release-notes.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/UpdatR/docs/README.md: -------------------------------------------------------------------------------- 1 | PLACEHOLDER -------------------------------------------------------------------------------- /src/dotnet-updatr/docs/README.md: -------------------------------------------------------------------------------- 1 | PLACEHOLDER -------------------------------------------------------------------------------- /src/UpdatR/docs/release-notes.txt: -------------------------------------------------------------------------------- 1 | PLACEHOLDER -------------------------------------------------------------------------------- /src/dotnet-updatr/docs/release-notes.txt: -------------------------------------------------------------------------------- 1 | PLACEHOLDER -------------------------------------------------------------------------------- /src/UpdatR/docs/README.source.md: -------------------------------------------------------------------------------- 1 | include: sdk-readme 2 | 3 | include: footer -------------------------------------------------------------------------------- /src/dotnet-updatr/docs/README.source.md: -------------------------------------------------------------------------------- 1 | include: cli-readme 2 | 3 | include: footer -------------------------------------------------------------------------------- /src/Build/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/src/Build/icon.png -------------------------------------------------------------------------------- /src/UpdatR/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/src/UpdatR/images/icon.png -------------------------------------------------------------------------------- /mdsource/footer.include.md: -------------------------------------------------------------------------------- 1 | # Icon 2 | Package by Sergey Novosyolov from [NounProject.com](http://NounProject.com) 3 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/dotnet-updatr/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/src/dotnet-updatr/images/icon.png -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.EmptyResults_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | emptyString -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.NothingToReport_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | emptyString -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.EmptyResults_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.KitchenSink_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update Updated.Package -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.NothingToReport_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.TwoUpdatedPackage_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update 2 packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackage_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.EmptyResults_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUnknownPackage_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackage_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update Updated.Package -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.UnauthorizedSource_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackage_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.-.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.NothingToReport_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.--has.-.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_excludedPackages=Dummy.--Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update Updated.Package -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=GenerateTitle.verified.txt: -------------------------------------------------------------------------------- 1 | 📦 Update no packages -------------------------------------------------------------------------------- /mdsource/README.source.md: -------------------------------------------------------------------------------- 1 | include: header 2 | 3 | # UpdatR packages 4 | 5 | include: cli-readme 6 | 7 | include: sdk-readme 8 | 9 | include: footer -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/Dummy/Dummy.App/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | Console.WriteLine("Hello, World!"); 3 | -------------------------------------------------------------------------------- /mdsource/header.include.md: -------------------------------------------------------------------------------- 1 | [![build](https://github.com/OskarKlintrot/UpdatR/actions/workflows/build.yml/badge.svg)](https://github.com/OskarKlintrot/UpdatR/actions/workflows/build.yml) -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.0.0.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.0.0.1.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.0.0.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.0.0.2.nupkg -------------------------------------------------------------------------------- /mdsnippets.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/SimonCropp/MarkdownSnippets/master/schema.json", 3 | "Convention": "SourceTransform", 4 | "OmitSnippetLinks": true 5 | } -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.Tool.0.0.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.Tool.0.0.1.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.Tool.0.0.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Dummy.Tool.0.0.2.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.12.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.12.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.16.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.16.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.17.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.17.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.5.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/dotnet-ef.5.0.5.nupkg -------------------------------------------------------------------------------- /src/BuildingBlocks/Paths.cs: -------------------------------------------------------------------------------- 1 | namespace BuildingBlocks; 2 | 3 | internal static class Paths 4 | { 5 | public static string Temporary => Path.Combine(Path.GetTempPath(), "dotnet-updatr"); 6 | } 7 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.1.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.2.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.3.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.3.1.0.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.5.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.5.0.0.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.6.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Newer.Tfm.6.0.0.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Templates/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.1-preview.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.1-preview.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.3-preview.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.3-preview.0.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.3-preview.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Has.Previews.0.0.3-preview.1.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Microsoft.EntityFrameworkCore.5.0.12.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Microsoft.EntityFrameworkCore.5.0.12.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Packages/Microsoft.EntityFrameworkCore.5.0.16.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OskarKlintrot/UpdatR/HEAD/tests/UpdatR.IntegrationTests/Resources/Packages/Microsoft.EntityFrameworkCore.5.0.16.nupkg -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUnknownPackage_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Not found packages 2 | 3 | ### Unknown.Package 4 | 5 | Used in: 6 | - Foo\Foo.csproj 7 | - Bar\Bar.csproj 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.UnauthorizedSource_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Unauthorized sources 2 | 3 | | Name | Source | 4 | |:-----|:-------| 5 | | Unauthorized source | https://google.com | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackage_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Vulnerable packages 2 | 3 | ### Vulnerable.Package 4 | 5 | #### Used in: 6 | - Foo\Foo.csproj 7 | - Bar\Bar.csproj 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUnknownPackage_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Not found packages 4 | 5 | ### Unknown.Package 6 | 7 | Used in: 8 | - Foo\Foo.csproj 9 | - Bar\Bar.csproj 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.UnauthorizedSource_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Unauthorized sources 4 | 5 | | Name | Source | 6 | |:-----|:-------| 7 | | Unauthorized source | https://google.com | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackage_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Vulnerable packages 4 | 5 | ### Vulnerable.Package 6 | 7 | #### Used in: 8 | - Foo\Foo.csproj 9 | - Bar\Bar.csproj 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Templates/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "": { 6 | "version": "", 7 | "commands": [ 8 | "" 9 | ] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Vulnerable packages 2 | 3 | ### Vulnerable.Package 4 | Version 1.2.3 with severity 1: https://google.com/ 5 | 6 | #### Used in: 7 | - Foo\Foo.csproj 8 | - Bar\Bar.csproj 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerability_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Vulnerable packages 4 | 5 | ### Vulnerable.Package 6 | Version 1.2.3 with severity 1: https://google.com/ 7 | 8 | #### Used in: 9 | - Foo\Foo.csproj 10 | - Bar\Bar.csproj 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackage_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | 1 package(s) were updated in 1 projects: 2 | 3 | | Updated.Package | 4 | 5 | ## Updated packages 6 | 7 | ### Updated.Package 8 | | Project | From | To | 9 | |:----------|:-------|:---| 10 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tools/Build/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Build": { 4 | "commandName": "Project", 5 | "commandLineArgs": "reset-generated-docs" 6 | }, 7 | "Build-WSL2": { 8 | "commandName": "WSL", 9 | "commandLineArgs": "Build.dll update-packages", 10 | "distributionName": "Ubuntu" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Vulnerable packages 2 | 3 | ### Vulnerable.Package 4 | Version 1.2.3 with severity 1: https://google.com/ 5 | Version 1.2.3 with severity 2: https://google.com/foo 6 | 7 | #### Used in: 8 | - Foo\Foo.csproj 9 | - Bar\Bar.csproj 10 | 11 | 12 | -------------------------------------------------------------------------------- /tools/Build/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-updatr": { 6 | "version": "4.0.0", 7 | "commands": [ 8 | "update" 9 | ] 10 | }, 11 | "markdownsnippets.tool": { 12 | "version": "27.0.2", 13 | "commands": [ 14 | "mdsnippets" 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Templates/Dummy.App.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackage_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update Updated.Package 2 | 3 | 1 package(s) were updated in 1 projects: 4 | 5 | | Updated.Package | 6 | 7 | ## Updated packages 8 | 9 | ### Updated.Package 10 | | Project | From | To | 11 | |:----------|:-------|:---| 12 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/UpdatR/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "UpdatR.Cli": { 4 | "commandName": "Project" 5 | }, 6 | "WSL": { 7 | "commandName": "WSL2", 8 | "environmentVariables": {}, 9 | "commandLineArgs": "UpdatR.Cli.dll --path /mnt/c/repos/UpdatR/UpdatR.sln --verbosity Debug", 10 | "distributionName": "Ubuntu" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.VulnerablePackageWithVulnerabilities_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Vulnerable packages 4 | 5 | ### Vulnerable.Package 6 | Version 1.2.3 with severity 1: https://google.com/ 7 | Version 1.2.3 with severity 2: https://google.com/foo 8 | 9 | #### Used in: 10 | - Foo\Foo.csproj 11 | - Bar\Bar.csproj 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Deprecated packages 2 | 3 | ### Deprecated.Package 4 | > Old and deprecated package. 5 | 6 | Reason(s): Other 7 | 8 | Package used in: 9 | 10 | | Project | Version | 11 | |:--------|:--------| 12 | | Foo\Foo.csproj | 1.2.3 | 13 | | Bar\Bar.csproj | 1.2.3 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | 1 package(s) were updated in 2 projects: 2 | 3 | | Updated.Package | 4 | 5 | ## Updated packages 6 | 7 | ### Updated.Package 8 | | Project | From | To | 9 | |:----------|:-------|:---| 10 | | Bar\Bar.csproj | 1.0.0 | 2.0.0 | 11 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Templates/.config/dotnet-tools2.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "": { 6 | "version": "", 7 | "commands": [ 8 | "" 9 | ] 10 | }, 11 | "": { 12 | "version": "", 13 | "commands": [ 14 | "" 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackageWithoutAlternative_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Deprecated packages 4 | 5 | ### Deprecated.Package 6 | > Old and deprecated package. 7 | 8 | Reason(s): Other 9 | 10 | Package used in: 11 | 12 | | Project | Version | 13 | |:--------|:--------| 14 | | Foo\Foo.csproj | 1.2.3 | 15 | | Bar\Bar.csproj | 1.2.3 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/UpdatR.SampleApp/UpdatR.SampleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.OneUpdatedPackageInTwoProjects_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update Updated.Package 2 | 3 | 1 package(s) were updated in 2 projects: 4 | 5 | | Updated.Package | 6 | 7 | ## Updated packages 8 | 9 | ### Updated.Package 10 | | Project | From | To | 11 | |:----------|:-------|:---| 12 | | Bar\Bar.csproj | 1.0.0 | 2.0.0 | 13 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackage_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | ## Deprecated packages 2 | 3 | ### Deprecated.Package 4 | > Old and deprecated package. 5 | 6 | Reason(s): Other 7 | 8 | Alternate Package: Not.Deprecated 9 | 10 | Version range: (, ) 11 | 12 | Package used in: 13 | 14 | | Project | Version | 15 | |:--------|:--------| 16 | | Foo\Foo.csproj | 1.2.3 | 17 | | Bar\Bar.csproj | 1.2.3 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.DeprecatedPackage_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update no packages 2 | 3 | ## Deprecated packages 4 | 5 | ### Deprecated.Package 6 | > Old and deprecated package. 7 | 8 | Reason(s): Other 9 | 10 | Alternate Package: Not.Deprecated 11 | 12 | Version range: (, ) 13 | 14 | Package used in: 15 | 16 | | Project | Version | 17 | |:--------|:--------| 18 | | Foo\Foo.csproj | 1.2.3 | 19 | | Bar\Bar.csproj | 1.2.3 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/update-docs.yml: -------------------------------------------------------------------------------- 1 | name: docs 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | update-docs: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v4 18 | with: 19 | dotnet-version: 6.x.x 20 | - name: Update README 21 | run: dotnet run -- update-README --parallel 22 | working-directory: tools/Build 23 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Paths.cs: -------------------------------------------------------------------------------- 1 | namespace UpdatR.IntegrationTests; 2 | 3 | internal static class Paths 4 | { 5 | public static string Packages => 6 | Path.Combine(Directory.GetCurrentDirectory(), "Resources", "Packages"); 7 | 8 | public static class Temporary 9 | { 10 | public static string Root => 11 | Path.Combine(Path.GetTempPath(), "dotnet-updatr", "integrationtests"); 12 | 13 | public static string Packages => Path.Combine(Root, "Packages"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.TwoUpdatedPackage_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | 2 package(s) were updated in 1 projects: 2 | 3 | | Updated.Package | Updated.Package.Abstracts | 4 | 5 | ## Updated packages 6 | 7 | ### Updated.Package 8 | | Project | From | To | 9 | |:----------|:-------|:---| 10 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 11 | 12 | ### Updated.Package.Abstracts 13 | | Project | From | To | 14 | |:----------|:-------|:---| 15 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.TwoUpdatedPackage_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update 2 packages 2 | 3 | 2 package(s) were updated in 1 projects: 4 | 5 | | Updated.Package | Updated.Package.Abstracts | 6 | 7 | ## Updated packages 8 | 9 | ### Updated.Package 10 | | Project | From | To | 11 | |:----------|:-------|:---| 12 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 13 | 14 | ### Updated.Package.Abstracts 15 | | Project | From | To | 16 | |:----------|:-------|:---| 17 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UpToDate_When_UpdateDotnetConfig_Then_DoNothing_version=0.0.2.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Dummy.Tool": { 9 | "version": "0.0.2", 10 | "commands": [ 11 | "dummy" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Dummy.Tool": { 23 | "version": "0.0.2", 24 | "commands": [ 25 | "dummy" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | ] -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: push packages 2 | 3 | on: 4 | push: 5 | tags: 6 | - v** 7 | 8 | jobs: 9 | push-packages: 10 | 11 | runs-on: ubuntu-latest 12 | environment: Push package 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v4 18 | with: 19 | dotnet-version: 6.x.x 20 | - name: Push NuGet Packages 21 | run: dotnet run -- push --parallel 22 | working-directory: tools/Build 23 | env: 24 | API_ACCESS_TOKEN: ${{ secrets.API_ACCESS_TOKEN }} 25 | -------------------------------------------------------------------------------- /src/dotnet-updatr/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "WSL": { 4 | "commandName": "WSL2", 5 | "commandLineArgs": "UpdatR.Cli.dll --path /mnt/c/repos/UpdatR/UpdatR.sln --verbosity Debug", 6 | "distributionName": "Ubuntu" 7 | }, 8 | "UpdatR.Cli --help": { 9 | "commandName": "Project", 10 | "commandLineArgs": "--help" 11 | }, 12 | "UpdatR.Cli": { 13 | "commandName": "Project", 14 | "commandLineArgs": "--dry-run", 15 | "workingDirectory": "C:\\_repos\\OskarKlintrot\\UpdatR\\tools\\Build" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | - update 9 | pull_request: 10 | branches: 11 | - main 12 | 13 | jobs: 14 | run-tests: 15 | 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Setup .NET 21 | uses: actions/setup-dotnet@v4 22 | with: 23 | dotnet-version: | 24 | 6.x.x 25 | 8.x.x 26 | - name: Run tests 27 | run: dotnet run -- test --parallel 28 | working-directory: tools/Build 29 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/Dummy/Dummy.App/Dummy.App.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: create release 2 | 3 | on: 4 | workflow_run: 5 | workflows: ["push packages"] 6 | types: 7 | - completed 8 | 9 | jobs: 10 | create-release: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v4 18 | with: 19 | dotnet-version: 6.x.x 20 | - name: Create GitHub Release 21 | run: dotnet run -- create-release --parallel 22 | working-directory: tools/Build 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | latest 6 | enable 7 | enable 8 | 9 | 10 | 11 | latest-Recommended 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/workflows/post-release.yml: -------------------------------------------------------------------------------- 1 | name: post release cleanup 2 | 3 | on: 4 | workflow_dispatch: 5 | workflow_run: 6 | workflows: ["push packages"] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | post-release-cleanup: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Setup .NET 18 | uses: actions/setup-dotnet@v4 19 | with: 20 | dotnet-version: 6.x.x 21 | - name: Clean up after release 22 | run: dotnet run -- post-release --parallel 23 | working-directory: tools/Build 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/Dummy/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage( 9 | "Performance", 10 | "CA1861:Avoid constant arrays as arguments", 11 | Justification = "Not important for unit tests", 12 | Scope = "member", 13 | Target = "~M:UpdatR.UnitTests.ProjectBuilder.WithDeprecatedPackage(System.String,System.String,System.String,System.Boolean)~UpdatR.UnitTests.ProjectBuilder" 14 | )] 15 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_DirectoryAsTarget_When_SingleDotnetConfig_Then_Update.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "Dummy.Tool": { 20 | "version": "0.0.1", 21 | "commands": [ 22 | "dummy" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "Dummy.Tool": { 34 | "version": "0.0.2", 35 | "commands": [ 36 | "dummy" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UpToDate_When_UpdateDotnetConfig_Then_DoNothing_version=0.0.1.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "Dummy.Tool": { 20 | "version": "0.0.1", 21 | "commands": [ 22 | "dummy" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "Dummy.Tool": { 34 | "version": "0.0.2", 35 | "commands": [ 36 | "dummy" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | ] -------------------------------------------------------------------------------- /src/BuildingBlocks/BuildingBlocks.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | a63910fe-f91f-4aa0-bf42-06b086f7556d 7 | 8 | 9 | BuildingBlocks 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mdsource/sdk-readme.include.md: -------------------------------------------------------------------------------- 1 | ## UpdatR 2 | 3 | [![Latest Nuget Version](https://badgen.net/nuget/v/UpdatR/latest)](https://www.nuget.org/packages/UpdatR/) 4 | [![Latest Nuget Version](https://badgen.net/nuget/dt/UpdatR)](https://www.nuget.org/packages/UpdatR/) 5 | 6 | NuGet package to programmatically update package reference and dotnet-tools.json. 7 | 8 | The tool will try to stick to package versions that is supported by the projects target framework moniker. If a package supports both .NETStandard and .NET, the compatibility with .NETStandard will be ignored if the project is targeting .NET. This is to avoid false positives where a package technically supports a TFM but in reality never have been tested against the TFM. 9 | 10 | See [dotnet-updatr](#dotnet-updatr) for a dotnet tool that can be run from the command-line. 11 | 12 | ### Usage 13 | 14 | snippet: SampleUsage 15 | -------------------------------------------------------------------------------- /tools/Build/Build.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | f8057ef4-f389-4c3d-bbc5-ec638d0454d7 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/UpdatR.SampleApp/Program.cs: -------------------------------------------------------------------------------- 1 | // CA1852 Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible 2 | #pragma warning disable CA1852 // <-- Disabled due to bug: https://github.com/dotnet/roslyn-analyzers/issues/6141 3 | 4 | // begin-snippet: SampleUsage 5 | using UpdatR; 6 | using UpdatR.Formatters; 7 | 8 | var updatr = new Updater(); // Can take an ILogger 9 | 10 | var summary = await updatr.UpdateAsync("path"); 11 | 12 | if (summary.UpdatedPackagesCount == 0) // No packages where updated 13 | { 14 | return; 15 | } 16 | 17 | var title = MarkdownFormatter.GenerateTitle(summary); 18 | 19 | var description = 20 | "# PR created automatically by UpdatR" 21 | + Environment.NewLine 22 | + Environment.NewLine 23 | + MarkdownFormatter.GenerateDescription(summary); 24 | 25 | // Use title as title in the PR and description as the description/body in the PR 26 | // end-snippet 27 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UpToDate_When_Update_Then_DoNothing_version=0.0.2.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | 5 | 6 | 7 | Exe 8 | net6.0 9 | enable 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Exe 21 | net6.0 22 | enable 23 | enable 24 | 25 | 26 | 27 | 28 | 29 | ] -------------------------------------------------------------------------------- /tests/DummyPackage/DummyPackage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | exe 5 | net6.0 6 | latest 7 | enable 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | <_Parameter1>$(ProjectDir) 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net5.0.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | 5 | 6 | 7 | Exe 8 | net6.0 9 | enable 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Exe 21 | net6.0 22 | enable 23 | enable 24 | 25 | 26 | 27 | 28 | 29 | ] -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [oskarklintrot] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: oskarklintrot # Replace with a single Buy Me a Coffee username 14 | thanks_dev: # Replace with a single thanks.dev username 15 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 16 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/UpdatR.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | all 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Initialization.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | namespace UpdatR.IntegrationTests; 4 | 5 | public static class Initialization 6 | { 7 | [ModuleInitializer] 8 | public static void Run() 9 | { 10 | if (Directory.Exists(Paths.Temporary.Root)) 11 | { 12 | Directory.Delete(Paths.Temporary.Root, true); 13 | } 14 | 15 | Directory.CreateDirectory(Paths.Temporary.Root); 16 | Directory.CreateDirectory(Paths.Temporary.Packages); 17 | 18 | CopyPackages(Paths.Temporary.Packages); 19 | } 20 | 21 | private static void CopyPackages(string source) 22 | { 23 | if (!Directory.Exists(source)) 24 | { 25 | throw new ArgumentException("Path not found.", nameof(source)); 26 | } 27 | 28 | foreach (var package in Directory.EnumerateFiles(Paths.Packages, "*.nupkg")) 29 | { 30 | File.Copy(package, Path.Combine(source, new FileInfo(package).Name), overwrite: true); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/Dummy/Dummy.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30114.105 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dummy.App", "Dummy.App\Dummy.App.csproj", "{3C97CFC9-CE58-4E2B-8D5E-4591270C362B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(SolutionProperties) = preSolution 14 | HideSolutionNode = FALSE 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {3C97CFC9-CE58-4E2B-8D5E-4591270C362B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {3C97CFC9-CE58-4E2B-8D5E-4591270C362B}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {3C97CFC9-CE58-4E2B-8D5E-4591270C362B}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {3C97CFC9-CE58-4E2B-8D5E-4591270C362B}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.KitchenSink_method=GenerateDescription.verified.txt: -------------------------------------------------------------------------------- 1 | 1 package(s) were updated in 1 projects: 2 | 3 | | Updated.Package | 4 | 5 | ## Vulnerable packages 6 | 7 | ### Vulnerable.Package 8 | Version 1.2.3 with severity 1: https://google.com/ 9 | 10 | #### Used in: 11 | - Foo\Foo.csproj 12 | 13 | 14 | ## Deprecated packages 15 | 16 | ### Deprecated.Package 17 | > Old and deprecated package. 18 | 19 | Reason(s): Other 20 | 21 | Alternate Package: Not.Deprecated 22 | 23 | Version range: (, ) 24 | 25 | Package used in: 26 | 27 | | Project | Version | 28 | |:--------|:--------| 29 | | Foo\Foo.csproj | 1.2.3 | 30 | 31 | 32 | ## Updated packages 33 | 34 | ### Updated.Package 35 | | Project | From | To | 36 | |:----------|:-------|:---| 37 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 38 | 39 | 40 | ## Not found packages 41 | 42 | ### Unknown.Package 43 | 44 | Used in: 45 | - Foo\Foo.csproj 46 | 47 | 48 | ## Unauthorized sources 49 | 50 | | Name | Source | 51 | |:-----|:-------| 52 | | Unauthorized source | https://google.com | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/BuildingBlocks/BuildingBlocks.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | a63910fe-f91f-4aa0-bf42-06b086f7556d 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | 5 | 6 | 7 | Exe 8 | net6.0 9 | enable 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Exe 22 | net6.0 23 | enable 24 | enable 25 | 26 | 27 | 28 | 29 | 30 | 31 | ] -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Formatters/MarkdownFormatterTests.KitchenSink_method=Generate.verified.txt: -------------------------------------------------------------------------------- 1 | # 📦 Update Updated.Package 2 | 3 | 1 package(s) were updated in 1 projects: 4 | 5 | | Updated.Package | 6 | 7 | ## Vulnerable packages 8 | 9 | ### Vulnerable.Package 10 | Version 1.2.3 with severity 1: https://google.com/ 11 | 12 | #### Used in: 13 | - Foo\Foo.csproj 14 | 15 | 16 | ## Deprecated packages 17 | 18 | ### Deprecated.Package 19 | > Old and deprecated package. 20 | 21 | Reason(s): Other 22 | 23 | Alternate Package: Not.Deprecated 24 | 25 | Version range: (, ) 26 | 27 | Package used in: 28 | 29 | | Project | Version | 30 | |:--------|:--------| 31 | | Foo\Foo.csproj | 1.2.3 | 32 | 33 | 34 | ## Updated packages 35 | 36 | ### Updated.Package 37 | | Project | From | To | 38 | |:----------|:-------|:---| 39 | | Foo\Foo.csproj | 1.0.0 | 2.0.0 | 40 | 41 | 42 | ## Not found packages 43 | 44 | ### Unknown.Package 45 | 46 | Used in: 47 | - Foo\Foo.csproj 48 | 49 | 50 | ## Unauthorized sources 51 | 52 | | Name | Source | 53 | |:-----|:-------| 54 | | Unauthorized source | https://google.com | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.--has.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | 5 | 6 | 7 | Exe 8 | net6.0 9 | enable 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Exe 22 | net6.0 23 | enable 24 | enable 25 | 26 | 27 | 28 | 29 | 30 | 31 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins_packages=Dummy.- Dummy.Tool.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [] 3 | 4 | 5 | 6 | 7 | Exe 8 | net6.0 9 | enable 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Exe 22 | net6.0 23 | enable 24 | enable 25 | 26 | 27 | 28 | 29 | 30 | 31 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Oskar Klintrot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/UpdatR.E2eTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | all 21 | 22 | 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | all 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_DirectoryAsTarget_When_SingleCsproj_Then_Update.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Exe 32 | net6.0 33 | enable 34 | enable 35 | 36 | 37 | 38 | 39 | 40 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UpToDate_When_Update_Then_DoNothing_version=0.0.1.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Exe 32 | net6.0 33 | enable 34 | enable 35 | 36 | 37 | 38 | 39 | 40 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net6.0.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Exe 32 | net6.0 33 | enable 34 | enable 35 | 36 | 37 | 38 | 39 | 40 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_TFM_When_UnsupportedInNewerVersions_Then_DoNothing_tfm=net7.0.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Exe 32 | net6.0 33 | enable 34 | enable 35 | 36 | 37 | 38 | 39 | 40 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_LatestPackageHasUnsupportedTfm_When_Update_Then_PickLatestSupportedTfm.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Has.Newer.Tfm, 5 | Updates: [ 6 | { 7 | Item1: 3.1.0, 8 | Item2: 5.0.0, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net5.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Exe 32 | net5.0 33 | enable 34 | enable 35 | 36 | 37 | 38 | 39 | 40 | ] -------------------------------------------------------------------------------- /.github/workflows/update.yml: -------------------------------------------------------------------------------- 1 | name: update packages 2 | 3 | on: 4 | schedule: 5 | # * is a special character in YAML so you have to quote this string 6 | - cron: '0 0 * * MON' # At 00:00, only on Monday 7 | push: 8 | paths: 9 | - 'tools/Build/.config/dotnet-tools.json' 10 | 11 | jobs: 12 | update-packages: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | if: github.event_name == 'push' 19 | - name: Checkout main 20 | uses: actions/checkout@v4 21 | if: github.event_name == 'schedule' 22 | with: 23 | ref: main 24 | - name: Setup .NET 25 | uses: actions/setup-dotnet@v4 26 | with: 27 | dotnet-version: 6.x.x 28 | - name: Update packages 29 | if: github.event_name == 'push' 30 | run: dotnet run -- update-packages --parallel 31 | working-directory: tools/Build 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | - name: Update packages and create PR 35 | if: github.event_name == 'schedule' 36 | run: dotnet run -- create-update-pr --parallel 37 | working-directory: tools/Build 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/TestOutputHelperTextWriterAdapter.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using Xunit.Abstractions; 3 | 4 | namespace UpdatR.E2e; 5 | 6 | internal sealed class TestOutputHelperTextWriterAdapter(ITestOutputHelper output) : TextWriter 7 | { 8 | private readonly ITestOutputHelper _output = output; 9 | 10 | private string _currentLine = string.Empty; 11 | 12 | public override Encoding Encoding { get; } = Encoding.UTF8; 13 | public bool Enabled { get; set; } = true; 14 | 15 | public override void Write(char value) 16 | { 17 | if (!Enabled) 18 | { 19 | return; 20 | } 21 | 22 | if (value == '\n') 23 | { 24 | WriteCurrentLine(); 25 | } 26 | else 27 | { 28 | _currentLine += value; 29 | } 30 | } 31 | 32 | private void WriteCurrentLine() 33 | { 34 | _output.WriteLine(_currentLine); 35 | 36 | _currentLine = string.Empty; 37 | } 38 | 39 | protected override void Dispose(bool disposing) 40 | { 41 | if (!string.IsNullOrWhiteSpace(_currentLine)) 42 | { 43 | WriteCurrentLine(); 44 | } 45 | 46 | base.Dispose(disposing); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Build/nuget.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Oskar Klintrot 5 | Copyright (c) Oskar Klintrot 2022 6 | icon.png 7 | README.md 8 | $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/docs/release-notes.txt")) 9 | MIT 10 | https://github.com/OskarKlintrot/UpdatR 11 | $(SolutionDir)/Artifacts 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | all 27 | runtime; build; native; contentfiles; analyzers 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Exe 33 | net6.0 34 | enable 35 | enable 36 | 37 | 38 | 39 | 40 | 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Has.Previews, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Exe 33 | net6.0 34 | enable 35 | enable 36 | 37 | 38 | 39 | 40 | 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.--Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Exe 33 | net6.0 34 | enable 35 | enable 36 | 37 | 38 | 39 | 40 | 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Dummy.--Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Has.Previews, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Exe 33 | net6.0 34 | enable 35 | enable 36 | 37 | 38 | 39 | 40 | 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageAndExcludedPackage_When_Update_Then_ExcludeWins_packages=Dummy.- Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | 16 | 17 | 18 | Exe 19 | net6.0 20 | enable 21 | enable 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Exe 33 | net6.0 34 | enable 35 | enable 36 | 37 | 38 | 39 | 40 | 41 | 42 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/Resources/Templates/Dummy.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30114.105 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{D2CF3675-9F2F-47F3-98C8-30FBB35E6088}" 7 | ProjectSection(SolutionItems) = preProject 8 | .config\dotnet-tools.json = .config\dotnet-tools.json 9 | EndProjectSection 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "", "", "{24D4763A-A7DD-40B6-B973-7565FD8F80E6}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {24D4763A-A7DD-40B6-B973-7565FD8F80E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {24D4763A-A7DD-40B6-B973-7565FD8F80E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {24D4763A-A7DD-40B6-B973-7565FD8F80E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {24D4763A-A7DD-40B6-B973-7565FD8F80E6}.Release|Any CPU.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdatR.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | all 18 | 19 | 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | all 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | PreserveNewest 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UnknownPackageId_When_Updating_Then_DoNothing_hasNugetConfig=False.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | 0 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Dummy.Tool": { 9 | "version": "0.0.1", 10 | "commands": [ 11 | "dummy" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Dummy.Tool": { 23 | "version": "0.0.1", 24 | "commands": [ 25 | "dummy" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | Exe 36 | net6.0 37 | enable 38 | enable 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Exe 49 | net6.0 50 | enable 51 | enable 52 | 53 | 54 | 55 | 56 | 57 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_UnknownPackageId_When_Updating_Then_DoNothing_hasNugetConfig=True.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | 2 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Dummy.Tool": { 9 | "version": "0.0.1", 10 | "commands": [ 11 | "dummy" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Dummy.Tool": { 23 | "version": "0.0.2", 24 | "commands": [ 25 | "dummy" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | Exe 36 | net6.0 37 | enable 38 | enable 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Exe 49 | net6.0 50 | enable 51 | enable 52 | 53 | 54 | 55 | 56 | 57 | ] -------------------------------------------------------------------------------- /src/BuildingBlocks/NuGetLogger.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace BuildingBlocks; 4 | 5 | internal sealed partial class NuGetLogger(ILogger logger) : NuGet.Common.LoggerBase 6 | { 7 | private readonly ILogger _logger = logger; 8 | 9 | public override void Log(NuGet.Common.ILogMessage message) 10 | { 11 | var logLevel = TranslateVerbosity(message.Level); 12 | 13 | Log(_logger, logLevel, message.Level, message.Message); 14 | } 15 | 16 | public override Task LogAsync(NuGet.Common.ILogMessage message) 17 | { 18 | Log(message); 19 | 20 | return Task.CompletedTask; 21 | } 22 | 23 | private static LogLevel TranslateVerbosity(NuGet.Common.LogLevel verbosity) => verbosity switch 24 | { 25 | NuGet.Common.LogLevel.Debug => LogLevel.Trace, 26 | NuGet.Common.LogLevel.Verbose => LogLevel.Debug, 27 | NuGet.Common.LogLevel.Information => LogLevel.Information, 28 | NuGet.Common.LogLevel.Minimal => LogLevel.Warning, 29 | NuGet.Common.LogLevel.Warning => LogLevel.Warning, 30 | NuGet.Common.LogLevel.Error => LogLevel.Error, 31 | _ => throw new NotImplementedException("Unknown verbosity."), 32 | }; 33 | 34 | [LoggerMessage(EventId = 0, Message = "nuget: ({NuGetLogLevel}): {Message}")] 35 | static partial void Log(ILogger logger, LogLevel level, NuGet.Common.LogLevel nuGetLogLevel, string message); 36 | } 37 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.1.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | 1 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Has.Previews": { 9 | "version": "0.0.1", 10 | "commands": [ 11 | "previews" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Has.Previews": { 23 | "version": "0.0.2", 24 | "commands": [ 25 | "previews" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | Exe 36 | net6.0 37 | enable 38 | enable 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Exe 49 | net6.0 50 | enable 51 | enable 52 | 53 | 54 | 55 | 56 | 57 | ] -------------------------------------------------------------------------------- /src/dotnet-updatr/dotnet-updatr.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Exe 9 | 10 | 11 | 12 | dotnet-updatr 13 | true 14 | update 15 | Tool to update NuGet packages. Supports package references and dotnet-tools.json. 16 | Update,NuGet,Packages,CI,CD 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.1-preview.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | 1 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Has.Previews": { 9 | "version": "0.0.1-preview", 10 | "commands": [ 11 | "previews" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Has.Previews": { 23 | "version": "0.0.2", 24 | "commands": [ 25 | "previews" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | Exe 36 | net6.0 37 | enable 38 | enable 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Exe 49 | net6.0 50 | enable 51 | enable 52 | 53 | 54 | 55 | 56 | 57 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_PackageWithPrerelease_When_Update_Then_StopAtStableIfPossible_version=0.0.3-preview.0.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | 1 3 | 4 | { 5 | "version": 1, 6 | "isRoot": true, 7 | "tools": { 8 | "Has.Previews": { 9 | "version": "0.0.3-preview.0", 10 | "commands": [ 11 | "previews" 12 | ] 13 | } 14 | } 15 | } 16 | 17 | 18 | { 19 | "version": 1, 20 | "isRoot": true, 21 | "tools": { 22 | "Has.Previews": { 23 | "version": "0.0.3-preview.1", 24 | "commands": [ 25 | "previews" 26 | ] 27 | } 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | Exe 36 | net6.0 37 | enable 38 | enable 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Exe 49 | net6.0 50 | enable 51 | enable 52 | 53 | 54 | 55 | 56 | 57 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Has.Previews, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\Dummy.App.csproj 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | 26 | 27 | 28 | Exe 29 | net6.0 30 | enable 31 | enable 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Exe 43 | net6.0 44 | enable 45 | enable 46 | 47 | 48 | 49 | 50 | 51 | 52 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Has.Previews, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\Dummy.App.csproj 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | 26 | 27 | 28 | Exe 29 | net6.0 30 | enable 31 | enable 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Exe 43 | net6.0 44 | enable 45 | enable 46 | 47 | 48 | 49 | 50 | 51 | 52 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_ExcludedPackage_When_Update_Then_DoNotUpdate_excludedPackages=Microsoft.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Has.Previews, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\Dummy.App.csproj 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | 26 | 27 | 28 | Exe 29 | net6.0 30 | enable 31 | enable 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Exe 43 | net6.0 44 | enable 45 | enable 46 | 47 | 48 | 49 | 50 | 51 | 52 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Packages_When_Update_Then_OnlyUpdateThatPackages_packages=Dummy.--has.-.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Has.Previews, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\Dummy.App.csproj 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | 26 | 27 | 28 | Exe 29 | net6.0 30 | enable 31 | enable 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Exe 43 | net6.0 44 | enable 45 | enable 46 | 47 | 48 | 49 | 50 | 51 | 52 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-.config.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "Dummy.Tool": { 20 | "version": "0.0.1", 21 | "commands": [ 22 | "dummy" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "Dummy.Tool": { 34 | "version": "0.0.2", 35 | "commands": [ 36 | "dummy" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | 46 | Exe 47 | net6.0 48 | enable 49 | enable 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Exe 60 | net6.0 61 | enable 62 | enable 63 | 64 | 65 | 66 | 67 | 68 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-.config-dotnet-tools.json.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy.Tool, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "Dummy.Tool": { 20 | "version": "0.0.1", 21 | "commands": [ 22 | "dummy" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "Dummy.Tool": { 34 | "version": "0.0.2", 35 | "commands": [ 36 | "dummy" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | 46 | Exe 47 | net6.0 48 | enable 49 | enable 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Exe 60 | net6.0 61 | enable 62 | enable 63 | 64 | 65 | 66 | 67 | 68 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=.config.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: dotnet-ef, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.12, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "dotnet-ef": { 20 | "version": "5.0.5", 21 | "commands": [ 22 | "dotnet" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "dotnet-ef": { 34 | "version": "5.0.12", 35 | "commands": [ 36 | "dotnet" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | 46 | Exe 47 | net5.0 48 | enable 49 | enable 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Exe 60 | net5.0 61 | enable 62 | enable 63 | 64 | 65 | 66 | 67 | 68 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=.config-dotnet-tools.json.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: dotnet-ef, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.12, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "dotnet-ef": { 20 | "version": "5.0.5", 21 | "commands": [ 22 | "dotnet" 23 | ] 24 | } 25 | } 26 | } 27 | 28 | 29 | { 30 | "version": 1, 31 | "isRoot": true, 32 | "tools": { 33 | "dotnet-ef": { 34 | "version": "5.0.12", 35 | "commands": [ 36 | "dotnet" 37 | ] 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | 46 | Exe 47 | net5.0 48 | enable 49 | enable 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Exe 60 | net5.0 61 | enable 62 | enable 63 | 64 | 65 | 66 | 67 | 68 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_DryRun_Then_DoNothing.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\.config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.1", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | 56 | Exe 57 | net6.0 58 | enable 59 | enable 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Exe 70 | net6.0 71 | enable 72 | enable 73 | 74 | 75 | 76 | 77 | 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: .config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.2", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | 56 | Exe 57 | net6.0 58 | enable 59 | enable 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Exe 70 | net6.0 71 | enable 72 | enable 73 | 74 | 75 | 76 | 77 | 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\.config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.2", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | 56 | Exe 57 | net6.0 58 | enable 59 | enable 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Exe 70 | net6.0 71 | enable 72 | enable 73 | 74 | 75 | 76 | 77 | 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=Dummy.sln.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\.config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.2", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | 56 | Exe 57 | net6.0 58 | enable 59 | enable 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Exe 70 | net6.0 71 | enable 72 | enable 73 | 74 | 75 | 76 | 77 | 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_Target_When_Valid_Then_Update_paths=src-Dummy.App.csproj.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: .config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.2", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | 56 | Exe 57 | net6.0 58 | enable 59 | enable 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Exe 70 | net6.0 71 | enable 72 | enable 73 | 74 | 75 | 76 | 77 | 78 | ] -------------------------------------------------------------------------------- /mdsource/cli-usage.txt: -------------------------------------------------------------------------------- 1 | Usage: 2 | update [] [options] 3 | 4 | Arguments: 5 | Path to solution or project(s). Defaults to current folder. Target can be a specific file or folder. If target is a folder then all *.csproj-files and dotnet-config.json-files will be processed. [default: .] 6 | 7 | Options: 8 | --package Package to update. Supports * as wildcard. Will update all unless specified. [] 9 | --exclude-package Package to exclude. Supports * as wildcard. [] 10 | --output Defaults to "output.md". Explicitly set to fileName.txt to generate plain text instead of markdown. [] 11 | --title Outputs title to path. [] 12 | --description <description> Outputs description to path. [] 13 | --verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Log level. [default: Warning] 14 | --dry-run Do not save any changes. [default: False] 15 | --prerelease Allow prerelease packages to be installed. [default: False] 16 | --browser Open summary in browser. [default: False] 17 | --interactive Interaction with user is possible. [default: False] 18 | --tfm <tfm> Lowest TFM to support. [] 19 | --version Show version information 20 | -?, -h, --help Show help and usage information 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_OutdatedDotnetEf_When_CsprojHasNewer_Then_UpdateToCsprojVersion_path=..verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Microsoft.EntityFrameworkCore, 5 | Updates: [ 6 | { 7 | Item1: 5.0.12, 8 | Item2: 5.0.16, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: dotnet-ef, 15 | Updates: [ 16 | { 17 | Item1: 5.0.5, 18 | Item2: 5.0.16, 19 | Item3: .config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "dotnet-ef": { 30 | "version": "5.0.5", 31 | "commands": [ 32 | "dotnet" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "dotnet-ef": { 44 | "version": "5.0.16", 45 | "commands": [ 46 | "dotnet" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | <?xml version="1.0" encoding="utf-8"?> 54 | <Project Sdk="Microsoft.NET.Sdk"> 55 | <PropertyGroup> 56 | <OutputType>Exe</OutputType> 57 | <TargetFramework>net5.0</TargetFramework> 58 | <ImplicitUsings>enable</ImplicitUsings> 59 | <Nullable>enable</Nullable> 60 | </PropertyGroup> 61 | <ItemGroup> 62 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" /> 63 | </ItemGroup> 64 | </Project> 65 | 66 | <?xml version="1.0" encoding="utf-8"?> 67 | <Project Sdk="Microsoft.NET.Sdk"> 68 | <PropertyGroup> 69 | <OutputType>Exe</OutputType> 70 | <TargetFramework>net5.0</TargetFramework> 71 | <ImplicitUsings>enable</ImplicitUsings> 72 | <Nullable>enable</Nullable> 73 | </PropertyGroup> 74 | <ItemGroup> 75 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.16" /> 76 | </ItemGroup> 77 | </Project> 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_OutdatedDotnetEf_When_UpdatingCsprojToNewer_Then_UpdateToCsprojVersion_path=..verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Microsoft.EntityFrameworkCore, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.16, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: dotnet-ef, 15 | Updates: [ 16 | { 17 | Item1: 5.0.5, 18 | Item2: 5.0.16, 19 | Item3: .config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "dotnet-ef": { 30 | "version": "5.0.5", 31 | "commands": [ 32 | "dotnet" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "dotnet-ef": { 44 | "version": "5.0.16", 45 | "commands": [ 46 | "dotnet" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | <?xml version="1.0" encoding="utf-8"?> 54 | <Project Sdk="Microsoft.NET.Sdk"> 55 | <PropertyGroup> 56 | <OutputType>Exe</OutputType> 57 | <TargetFramework>net5.0</TargetFramework> 58 | <ImplicitUsings>enable</ImplicitUsings> 59 | <Nullable>enable</Nullable> 60 | </PropertyGroup> 61 | <ItemGroup> 62 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" /> 63 | </ItemGroup> 64 | </Project> 65 | 66 | <?xml version="1.0" encoding="utf-8"?> 67 | <Project Sdk="Microsoft.NET.Sdk"> 68 | <PropertyGroup> 69 | <OutputType>Exe</OutputType> 70 | <TargetFramework>net5.0</TargetFramework> 71 | <ImplicitUsings>enable</ImplicitUsings> 72 | <Nullable>enable</Nullable> 73 | </PropertyGroup> 74 | <ItemGroup> 75 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.16" /> 76 | </ItemGroup> 77 | </Project> 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_MultiplePackagesInDotnetTools_When_OneOutdated_Then_UpdateThatOne_path=.config.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: dotnet-ef, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.12, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "dotnet-ef": { 20 | "version": "5.0.5", 21 | "commands": [ 22 | "dotnet" 23 | ] 24 | }, 25 | "Dummy.Tool": { 26 | "version": "0.0.2", 27 | "commands": [ 28 | "dummy" 29 | ] 30 | } 31 | } 32 | } 33 | 34 | 35 | { 36 | "version": 1, 37 | "isRoot": true, 38 | "tools": { 39 | "dotnet-ef": { 40 | "version": "5.0.12", 41 | "commands": [ 42 | "dotnet" 43 | ] 44 | }, 45 | "Dummy.Tool": { 46 | "version": "0.0.2", 47 | "commands": [ 48 | "dummy" 49 | ] 50 | } 51 | } 52 | } 53 | 54 | 55 | <?xml version="1.0" encoding="utf-8"?> 56 | <Project Sdk="Microsoft.NET.Sdk"> 57 | <PropertyGroup> 58 | <OutputType>Exe</OutputType> 59 | <TargetFramework>net5.0</TargetFramework> 60 | <ImplicitUsings>enable</ImplicitUsings> 61 | <Nullable>enable</Nullable> 62 | </PropertyGroup> 63 | <ItemGroup> 64 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" /> 65 | </ItemGroup> 66 | </Project> 67 | 68 | <?xml version="1.0" encoding="utf-8"?> 69 | <Project Sdk="Microsoft.NET.Sdk"> 70 | <PropertyGroup> 71 | <OutputType>Exe</OutputType> 72 | <TargetFramework>net5.0</TargetFramework> 73 | <ImplicitUsings>enable</ImplicitUsings> 74 | <Nullable>enable</Nullable> 75 | </PropertyGroup> 76 | <ItemGroup> 77 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" /> 78 | </ItemGroup> 79 | </Project> 80 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_OutdatedDotnetEf_When_UpdatingCsprojToNewer_Then_UpdateToCsprojVersion_path=Dummy.sln.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Microsoft.EntityFrameworkCore, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.16, 9 | Item3: Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: dotnet-ef, 15 | Updates: [ 16 | { 17 | Item1: 5.0.5, 18 | Item2: 5.0.16, 19 | Item3: .config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "dotnet-ef": { 30 | "version": "5.0.5", 31 | "commands": [ 32 | "dotnet" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "dotnet-ef": { 44 | "version": "5.0.16", 45 | "commands": [ 46 | "dotnet" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | <?xml version="1.0" encoding="utf-8"?> 54 | <Project Sdk="Microsoft.NET.Sdk"> 55 | <PropertyGroup> 56 | <OutputType>Exe</OutputType> 57 | <TargetFramework>net5.0</TargetFramework> 58 | <ImplicitUsings>enable</ImplicitUsings> 59 | <Nullable>enable</Nullable> 60 | </PropertyGroup> 61 | <ItemGroup> 62 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" /> 63 | </ItemGroup> 64 | </Project> 65 | 66 | <?xml version="1.0" encoding="utf-8"?> 67 | <Project Sdk="Microsoft.NET.Sdk"> 68 | <PropertyGroup> 69 | <OutputType>Exe</OutputType> 70 | <TargetFramework>net5.0</TargetFramework> 71 | <ImplicitUsings>enable</ImplicitUsings> 72 | <Nullable>enable</Nullable> 73 | </PropertyGroup> 74 | <ItemGroup> 75 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.16" /> 76 | </ItemGroup> 77 | </Project> 78 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_MultiplePackagesInDotnetTools_When_OneOutdated_Then_UpdateThatOne_path=.config-dotnet-tools.json.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: dotnet-ef, 5 | Updates: [ 6 | { 7 | Item1: 5.0.5, 8 | Item2: 5.0.12, 9 | Item3: dotnet-tools.json 10 | } 11 | ] 12 | } 13 | ] 14 | 15 | { 16 | "version": 1, 17 | "isRoot": true, 18 | "tools": { 19 | "dotnet-ef": { 20 | "version": "5.0.5", 21 | "commands": [ 22 | "dotnet" 23 | ] 24 | }, 25 | "Dummy.Tool": { 26 | "version": "0.0.2", 27 | "commands": [ 28 | "dummy" 29 | ] 30 | } 31 | } 32 | } 33 | 34 | 35 | { 36 | "version": 1, 37 | "isRoot": true, 38 | "tools": { 39 | "dotnet-ef": { 40 | "version": "5.0.12", 41 | "commands": [ 42 | "dotnet" 43 | ] 44 | }, 45 | "Dummy.Tool": { 46 | "version": "0.0.2", 47 | "commands": [ 48 | "dummy" 49 | ] 50 | } 51 | } 52 | } 53 | 54 | 55 | <?xml version="1.0" encoding="utf-8"?> 56 | <Project Sdk="Microsoft.NET.Sdk"> 57 | <PropertyGroup> 58 | <OutputType>Exe</OutputType> 59 | <TargetFramework>net5.0</TargetFramework> 60 | <ImplicitUsings>enable</ImplicitUsings> 61 | <Nullable>enable</Nullable> 62 | </PropertyGroup> 63 | <ItemGroup> 64 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" /> 65 | </ItemGroup> 66 | </Project> 67 | 68 | <?xml version="1.0" encoding="utf-8"?> 69 | <Project Sdk="Microsoft.NET.Sdk"> 70 | <PropertyGroup> 71 | <OutputType>Exe</OutputType> 72 | <TargetFramework>net5.0</TargetFramework> 73 | <ImplicitUsings>enable</ImplicitUsings> 74 | <Nullable>enable</Nullable> 75 | </PropertyGroup> 76 | <ItemGroup> 77 | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" /> 78 | </ItemGroup> 79 | </Project> 80 | ] -------------------------------------------------------------------------------- /src/UpdatR/UpdatR.csproj: -------------------------------------------------------------------------------- 1 | <Project Sdk="Microsoft.NET.Sdk"> 2 | 3 | <Import Project="..\BuildingBlocks\BuildingBlocks.projitems" Label="Shared" /> 4 | 5 | <Import Project="$(MSBuildProjectDirectory)\..\Build\nuget.props" /> 6 | 7 | <PropertyGroup> 8 | <PackageId>UpdatR</PackageId> 9 | <Description>Package to update NuGet packages. Supports package references and dotnet-tools.json.</Description> 10 | <PackageTags>Update,NuGet,Packages,CI,CD</PackageTags> 11 | <GeneratePackageOnBuild Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">true</GeneratePackageOnBuild> 12 | </PropertyGroup> 13 | 14 | <ItemGroup> 15 | <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" /> 16 | <PackageReference Include="NuGet.Credentials" Version="6.12.1" /> 17 | <PackageReference Include="NuGet.Protocol" Version="6.12.1" /> 18 | <PackageReference Include="NuGet.Versioning" Version="6.12.1" /> 19 | </ItemGroup> 20 | 21 | <ItemGroup> 22 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> 23 | <_Parameter1>$(MSBuildProjectName).UnitTests</_Parameter1> 24 | </AssemblyAttribute> 25 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> 26 | <_Parameter1>$(RootNamespace).UnitTests</_Parameter1> 27 | </AssemblyAttribute> 28 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> 29 | <_Parameter1>$(MSBuildProjectName).IntegrationTests</_Parameter1> 30 | </AssemblyAttribute> 31 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> 32 | <_Parameter1>$(RootNamespace).IntegrationTests</_Parameter1> 33 | </AssemblyAttribute> 34 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> 35 | <!-- For Moq --> 36 | <_Parameter1>DynamicProxyGenAssembly2</_Parameter1> 37 | </AssemblyAttribute> 38 | </ItemGroup> 39 | 40 | </Project> 41 | -------------------------------------------------------------------------------- /src/UpdatR/Domain/Utils/RetriveTargetFramework.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace UpdatR.Domain.Utils; 4 | 5 | internal static class RetriveTargetFramework 6 | { 7 | public static string? GetTargetFrameworkFromDirectoryBuildProps(DirectoryInfo path) 8 | { 9 | var file = GetDirectoryBuildProps(path); 10 | 11 | var targetFramework = file is null ? null : GetTargetFramework(file.FullName); 12 | 13 | while (targetFramework is null) 14 | { 15 | // Make sure we don't try to go beyond C:\ 16 | if (Path.GetPathRoot(path.FullName) == path.FullName) 17 | { 18 | return null; 19 | } 20 | 21 | if (file is null || ImportsFromAbove(file)) 22 | { 23 | path = path.Parent!; 24 | 25 | file = GetDirectoryBuildProps(path); 26 | 27 | targetFramework = file is null ? null : GetTargetFramework(file.FullName); 28 | } 29 | else 30 | { 31 | return null; 32 | } 33 | } 34 | 35 | return targetFramework; 36 | 37 | static FileInfo? GetDirectoryBuildProps(DirectoryInfo path) 38 | { 39 | return path.GetFiles( 40 | "Directory.Build.props", 41 | new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive } 42 | ) 43 | .FirstOrDefault(); 44 | } 45 | } 46 | 47 | public static bool ImportsFromAbove(FileInfo file) 48 | { 49 | var doc = new XmlDocument(); 50 | 51 | doc.Load(file.FullName); 52 | 53 | // Check if current Directory.Build.props imports another Directory.Build.props: 54 | // <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> 55 | 56 | return doc.SelectSingleNode( 57 | "//Import[@Project=\"$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))\"]" 58 | ) 59 | is not null; 60 | } 61 | 62 | public static string? GetTargetFramework(string path) 63 | { 64 | var doc = new XmlDocument(); 65 | 66 | doc.Load(path); 67 | 68 | return doc.SelectNodes("/Project/PropertyGroup/TargetFramework") 69 | ?.OfType<XmlElement>() 70 | .SingleOrDefault() 71 | ?.InnerText; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_CsprojNotAddedToSln_When_TargetSln_Then_DoNothing_target=Dummy.sln.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | } 11 | ] 12 | }, 13 | { 14 | PackageId: Dummy.Tool, 15 | Updates: [ 16 | { 17 | Item1: 0.0.1, 18 | Item2: 0.0.2, 19 | Item3: src\.config\dotnet-tools.json 20 | } 21 | ] 22 | } 23 | ] 24 | 25 | { 26 | "version": 1, 27 | "isRoot": true, 28 | "tools": { 29 | "Dummy.Tool": { 30 | "version": "0.0.1", 31 | "commands": [ 32 | "dummy" 33 | ] 34 | } 35 | } 36 | } 37 | 38 | 39 | { 40 | "version": 1, 41 | "isRoot": true, 42 | "tools": { 43 | "Dummy.Tool": { 44 | "version": "0.0.2", 45 | "commands": [ 46 | "dummy" 47 | ] 48 | } 49 | } 50 | } 51 | 52 | 53 | <?xml version="1.0" encoding="utf-8"?> 54 | <Project Sdk="Microsoft.NET.Sdk"> 55 | <PropertyGroup> 56 | <OutputType>Exe</OutputType> 57 | <TargetFramework>net6.0</TargetFramework> 58 | <ImplicitUsings>enable</ImplicitUsings> 59 | <Nullable>enable</Nullable> 60 | </PropertyGroup> 61 | <ItemGroup> 62 | <PackageReference Include="Dummy" Version="0.0.1" /> 63 | </ItemGroup> 64 | </Project> 65 | 66 | <?xml version="1.0" encoding="utf-8"?> 67 | <Project Sdk="Microsoft.NET.Sdk"> 68 | <PropertyGroup> 69 | <OutputType>Exe</OutputType> 70 | <TargetFramework>net6.0</TargetFramework> 71 | <ImplicitUsings>enable</ImplicitUsings> 72 | <Nullable>enable</Nullable> 73 | </PropertyGroup> 74 | <ItemGroup> 75 | <PackageReference Include="Dummy" Version="0.0.2" /> 76 | </ItemGroup> 77 | </Project> 78 | 79 | <?xml version="1.0" encoding="utf-8"?> 80 | <Project Sdk="Microsoft.NET.Sdk"> 81 | <PropertyGroup> 82 | <OutputType>Exe</OutputType> 83 | <TargetFramework>net6.0</TargetFramework> 84 | <ImplicitUsings>enable</ImplicitUsings> 85 | <Nullable>enable</Nullable> 86 | </PropertyGroup> 87 | <ItemGroup> 88 | <PackageReference Include="Dummy" Version="0.0.1" /> 89 | </ItemGroup> 90 | </Project> 91 | 92 | <?xml version="1.0" encoding="utf-8"?> 93 | <Project Sdk="Microsoft.NET.Sdk"> 94 | <PropertyGroup> 95 | <OutputType>Exe</OutputType> 96 | <TargetFramework>net6.0</TargetFramework> 97 | <ImplicitUsings>enable</ImplicitUsings> 98 | <Nullable>enable</Nullable> 99 | </PropertyGroup> 100 | <ItemGroup> 101 | <PackageReference Include="Dummy" Version="0.0.1" /> 102 | </ItemGroup> 103 | </Project> 104 | ] -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/UpdaterTests.Given_CsprojNotAddedToSln_When_TargetSln_Then_DoNothing_target=.verified.txt: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | { 4 | PackageId: Dummy, 5 | Updates: [ 6 | { 7 | Item1: 0.0.1, 8 | Item2: 0.0.2, 9 | Item3: src\Dummy.App.csproj 10 | }, 11 | { 12 | Item1: 0.0.1, 13 | Item2: 0.0.2, 14 | Item3: src\Dummy.Lib.csproj 15 | } 16 | ] 17 | }, 18 | { 19 | PackageId: Dummy.Tool, 20 | Updates: [ 21 | { 22 | Item1: 0.0.1, 23 | Item2: 0.0.2, 24 | Item3: src\.config\dotnet-tools.json 25 | } 26 | ] 27 | } 28 | ] 29 | 30 | { 31 | "version": 1, 32 | "isRoot": true, 33 | "tools": { 34 | "Dummy.Tool": { 35 | "version": "0.0.1", 36 | "commands": [ 37 | "dummy" 38 | ] 39 | } 40 | } 41 | } 42 | 43 | 44 | { 45 | "version": 1, 46 | "isRoot": true, 47 | "tools": { 48 | "Dummy.Tool": { 49 | "version": "0.0.2", 50 | "commands": [ 51 | "dummy" 52 | ] 53 | } 54 | } 55 | } 56 | 57 | 58 | <?xml version="1.0" encoding="utf-8"?> 59 | <Project Sdk="Microsoft.NET.Sdk"> 60 | <PropertyGroup> 61 | <OutputType>Exe</OutputType> 62 | <TargetFramework>net6.0</TargetFramework> 63 | <ImplicitUsings>enable</ImplicitUsings> 64 | <Nullable>enable</Nullable> 65 | </PropertyGroup> 66 | <ItemGroup> 67 | <PackageReference Include="Dummy" Version="0.0.1" /> 68 | </ItemGroup> 69 | </Project> 70 | 71 | <?xml version="1.0" encoding="utf-8"?> 72 | <Project Sdk="Microsoft.NET.Sdk"> 73 | <PropertyGroup> 74 | <OutputType>Exe</OutputType> 75 | <TargetFramework>net6.0</TargetFramework> 76 | <ImplicitUsings>enable</ImplicitUsings> 77 | <Nullable>enable</Nullable> 78 | </PropertyGroup> 79 | <ItemGroup> 80 | <PackageReference Include="Dummy" Version="0.0.2" /> 81 | </ItemGroup> 82 | </Project> 83 | 84 | <?xml version="1.0" encoding="utf-8"?> 85 | <Project Sdk="Microsoft.NET.Sdk"> 86 | <PropertyGroup> 87 | <OutputType>Exe</OutputType> 88 | <TargetFramework>net6.0</TargetFramework> 89 | <ImplicitUsings>enable</ImplicitUsings> 90 | <Nullable>enable</Nullable> 91 | </PropertyGroup> 92 | <ItemGroup> 93 | <PackageReference Include="Dummy" Version="0.0.1" /> 94 | </ItemGroup> 95 | </Project> 96 | 97 | <?xml version="1.0" encoding="utf-8"?> 98 | <Project Sdk="Microsoft.NET.Sdk"> 99 | <PropertyGroup> 100 | <OutputType>Exe</OutputType> 101 | <TargetFramework>net6.0</TargetFramework> 102 | <ImplicitUsings>enable</ImplicitUsings> 103 | <Nullable>enable</Nullable> 104 | </PropertyGroup> 105 | <ItemGroup> 106 | <PackageReference Include="Dummy" Version="0.0.2" /> 107 | </ItemGroup> 108 | </Project> 109 | ] -------------------------------------------------------------------------------- /mdsource/cli-readme.include.md: -------------------------------------------------------------------------------- 1 | ## dotnet-updatr 2 | 3 | [![Latest Nuget Version](https://badgen.net/nuget/v/dotnet-updatr/latest)](https://www.nuget.org/packages/dotnet-updatr/) 4 | [![Latest Nuget Version](https://badgen.net/nuget/dt/dotnet-updatr)](https://www.nuget.org/packages/dotnet-updatr/) 5 | 6 | Dotnet tool for updating package reference and dotnet-tools.json. 7 | 8 | The tool will try to stick to package versions that is supported by the projects target framework moniker. If a package supports both .NETStandard and .NET, the compatibility with .NETStandard will be ignored if the project is targeting .NET. This is to avoid false positives where a package technically supports a TFM but in reality never have been tested against the TFM. 9 | 10 | See [UpdatR](#updatr) for SDK. 11 | 12 | ### Installation 13 | 14 | ``` 15 | > dotnet tool install --global dotnet-updatr 16 | ``` 17 | 18 | ### Basic Usage 19 | 20 | To update all `*.csproj` and `dotnet-tools.json` recursively: 21 | 22 | ``` 23 | > update 24 | ``` 25 | 26 | If you only want to update the `*.csproj` and `dotnet-tools.json` that is part of a solution you can specify the solution directly: 27 | 28 | ``` 29 | > update path/to/solution.sln 30 | ``` 31 | 32 | You can also update a single `*.csproj` or `dotnet-config.json`: 33 | 34 | ``` 35 | > update path/to/example.csproj 36 | ``` 37 | 38 | If you want to preview the result you can do a dry run: 39 | 40 | ``` 41 | > update --dry-run 42 | ``` 43 | 44 | For larger solutions with multiple packages the console output is not optimal. You can choose to view the result in your default browser instead: 45 | 46 | ``` 47 | > update --browser 48 | ``` 49 | 50 | To allow packages to be updated to prerelease versions use the `--prerelease` options: 51 | 52 | ``` 53 | > update --prerelease 54 | ``` 55 | 56 | To update only one or more specific packages you can use the `--package` option: 57 | 58 | ``` 59 | > update --package Microsoft.* --package Newtonsoft.* 60 | ``` 61 | 62 | If you don't want to update a package or packages you can exclude them: 63 | 64 | ``` 65 | > update --exclude-package Microsoft.* --exclude-package Newtonsoft.* 66 | ``` 67 | 68 | If UpdatR fails to find the correct lowest TFM to support, for example for projects that supports multiple TFM's, then it's possible to set the TFM manually: 69 | 70 | ``` 71 | > update --tfm net6.0 72 | ``` 73 | 74 | ### As part of CI/CD 75 | 76 | You can get the output as a markdown by setting a path for the output: 77 | 78 | ``` 79 | > update --output path/to/output/folder 80 | ``` 81 | 82 | It's possible to get the title and the rest of the output as separate .md-files which is helpful when creating a pull request: 83 | 84 | ``` 85 | > update --title path/to/title.md --description path/to/description.md 86 | ``` 87 | 88 | then you can use `title.md` as the title for your pull request and `description.md` as the body. 89 | 90 | UpdatR is used to update it's own dependencies, have a look at [Build.cs](https://github.com/OskarKlintrot/UpdatR/blob/main/tools/Build/Build.cs) for an example that uses [Bullseye](https://www.nuget.org/packages/Bullseye) and [SimpleExec](https://www.nuget.org/packages/SimpleExec). However, if you are using C# in your CI/CD pipeline it's probably easier to just use [UpdatR](#updatr) directly instead. That's the package that powers `dotnet-updatr` under the hood. 91 | 92 | ### All options 93 | 94 | snippet: cli-usage.txt -------------------------------------------------------------------------------- /tests/DummyPackage/Build.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Bullseye; 3 | using McMaster.Extensions.CommandLineUtils; 4 | using NuGet.Versioning; 5 | using static Bullseye.Targets; 6 | using static SimpleExec.Command; 7 | 8 | using var app = new CommandLineApplication() { UsePagerForHelpText = false }; 9 | app.HelpOption(); 10 | var version = app.Option<string>( 11 | "-v|--version <version>", 12 | "Version of the package.", 13 | CommandOptionType.SingleValue 14 | ); 15 | var packageIdOption = app.Option<string>( 16 | "-id|--packageId <package-id>", 17 | "Name of the package.", 18 | CommandOptionType.SingleValue 19 | ); 20 | var targetFrameworkOption = app.Option<string>( 21 | "-tfm|--target-framework <tfm>", 22 | "Target framework of the package.", 23 | CommandOptionType.SingleValue, 24 | conf => conf.DefaultValue = "net6.0" 25 | ); 26 | var isToolOption = app.Option<bool>("-t|--is-tool", "Pack as tool.", CommandOptionType.NoValue); 27 | 28 | // translate from Bullseye to McMaster.Extensions.CommandLineUtils 29 | app.Argument( 30 | "targets", 31 | "A list of targets to run or list. If not specified, the \"default\" target will be run, or all targets will be listed.", 32 | true 33 | ); 34 | foreach (var (aliases, description) in Options.Definitions) 35 | { 36 | _ = app.Option(string.Join("|", aliases), description, CommandOptionType.NoValue); 37 | } 38 | 39 | app.OnExecuteAsync( 40 | async _ => 41 | { 42 | var msbuild = Assembly 43 | .GetEntryAssembly()! 44 | .GetCustomAttribute<MsBuildConfigurationAttribute>()!; 45 | 46 | // translate from McMaster.Extensions.CommandLineUtils to Bullseye 47 | var targets = app.Arguments[0].Values.OfType<string>(); 48 | var options = new Options( 49 | Options.Definitions.Select( 50 | d => 51 | ( 52 | d.Aliases[0], 53 | app.Options.Single(o => d.Aliases.Contains($"--{o.LongName}")).HasValue() 54 | ) 55 | ) 56 | ); 57 | 58 | var nuGetVersion = NuGetVersion.Parse(version.Value()); 59 | var packageId = packageIdOption.Value(); 60 | var tfm = targetFrameworkOption.Value(); 61 | var isTool = isToolOption.HasValue(); 62 | 63 | Target( 64 | "default", 65 | async () => 66 | { 67 | await Console.Out.WriteLineAsync($"version: {nuGetVersion}"); 68 | await Console.Out.WriteLineAsync($"packageId: {packageId}"); 69 | await Console.Out.WriteLineAsync($"tfm: {tfm}"); 70 | await Console.Out.WriteLineAsync($"is tool: {isTool}"); 71 | 72 | await RunAsync( 73 | "dotnet", 74 | $"pack --configuration Release -p:version=\"{nuGetVersion}\" -p:packageId=\"{packageId}\" -p:targetFramework=\"{tfm}\" -p:packAsTool=\"{isTool}\" {msbuild.ProjectDir} --output ." 75 | ); 76 | } 77 | ); 78 | 79 | Target( 80 | "push", 81 | DependsOn("default"), 82 | async () => 83 | { 84 | await RunAsync( 85 | "dotnet", 86 | $"nuget push .\\{packageId}.{nuGetVersion}.nupkg --api-key AzureDevOps --source https://pkgs.dev.azure.com/curium/0329093f-bb7c-41c0-9e4c-893f37483900/_packaging/broken-parts/nuget/v3/index.json --interactive" 87 | ); 88 | } 89 | ); 90 | 91 | await RunTargetsAndExitAsync(targets, options); 92 | } 93 | ); 94 | 95 | return await app.ExecuteAsync(args); 96 | 97 | [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] 98 | sealed class MsBuildConfigurationAttribute : Attribute 99 | { 100 | public string ProjectDir { get; } 101 | 102 | public MsBuildConfigurationAttribute(string projectDir) 103 | { 104 | ProjectDir = projectDir; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/UpdatR/Domain/NuGetPackage.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using NuGet.Frameworks; 3 | using NuGet.Versioning; 4 | using UpdatR.Internals; 5 | 6 | namespace UpdatR.Domain; 7 | 8 | [SuppressMessage("Style", "IDE0022:Use block body for method", Justification = "<Pending>")] 9 | internal record NuGetPackage(string PackageId, IEnumerable<PackageMetadata> PackageMetadatas) 10 | { 11 | private PackageMetadata? _latest; 12 | private PackageMetadata? _latestStable; 13 | private PackageMetadata? _latestPrerelease; 14 | private CompatibilityProvider? _compatibilityProvider; 15 | 16 | private CompatibilityProvider CompatibilityProvider => 17 | _compatibilityProvider ??= new CompatibilityProvider(DefaultFrameworkNameProvider.Instance); 18 | 19 | private PackageMetadata? LatestStable(NuGetFramework targetFramework) => 20 | _latestStable ??= Latest(targetFramework, x => !x.Version.IsPrerelease); 21 | 22 | private PackageMetadata? LatestPrerelease(NuGetFramework targetFramework) => 23 | _latestPrerelease ??= Latest(targetFramework, x => x.Version.IsPrerelease); 24 | 25 | private PackageMetadata? Latest(NuGetFramework targetFramework) => 26 | _latest ??= Latest(targetFramework, _ => true); 27 | 28 | private PackageMetadata? Latest( 29 | NuGetFramework targetFramework, 30 | Func<PackageMetadata, bool> predicate 31 | ) => 32 | PackageMetadatas 33 | .Where(x => predicate(x) && IsCompatibleWithFramework(targetFramework, x)) // Todo: Bodge for tools 34 | .OrderByDescending(x => x.Version) 35 | .FirstOrDefault(); 36 | 37 | private bool IsCompatibleWithFramework( 38 | NuGetFramework targetFramework, 39 | PackageMetadata package 40 | ) => 41 | !package.TargetFrameworks.Any() 42 | || ( 43 | package.TargetFrameworks.All(x => 44 | x.Framework == ".NETStandard" || targetFramework.Framework != x.Framework 45 | ) 46 | ? package.TargetFrameworks 47 | : package.TargetFrameworks.Where(x => 48 | targetFramework.Framework == ".NETStandard" || x.Framework != ".NETStandard" 49 | ) 50 | ).Any(x => CompatibilityProvider.IsCompatible(targetFramework, x)); 51 | 52 | /// <summary> 53 | /// Get latest stable if <paramref name="version"/> is stable and older than <see cref="LatestStable"/>. 54 | /// If <paramref name="version"/> is prerelase then take latest prerelease unless there is a newer stable version. 55 | /// </summary> 56 | /// <param name="version">Current version to compare to.</param> 57 | /// <param name="package"></param> 58 | /// <param name="usePrerelease">Use prerelase, even if <paramref name="version"/> is stable.</param> 59 | /// <returns><see langword="true"/> if a newer version is avalible.</returns> 60 | public bool TryGetLatestComparedTo( 61 | NuGetVersion version, 62 | NuGetFramework targetFramework, 63 | bool usePrerelease, 64 | [NotNullWhen(returnValue: true)] out PackageMetadata? package 65 | ) 66 | { 67 | if (usePrerelease) 68 | { 69 | package = Latest(targetFramework)!; 70 | 71 | return true; 72 | } 73 | else if ((LatestStable(targetFramework)?.Version ?? NuGetVersion.Parse("0.0.0")) > version) 74 | { 75 | package = LatestStable(targetFramework)!; 76 | 77 | return true; 78 | } 79 | else if ( 80 | version.IsPrerelease 81 | && (LatestPrerelease(targetFramework)?.Version ?? NuGetVersion.Parse("0.0.0")) > version 82 | ) 83 | { 84 | package = LatestPrerelease(targetFramework)!; 85 | 86 | return true; 87 | } 88 | 89 | package = null; 90 | 91 | return false; 92 | } 93 | 94 | public bool TryGet( 95 | NuGetVersion version, 96 | [NotNullWhen(returnValue: true)] out PackageMetadata? package 97 | ) 98 | { 99 | package = PackageMetadatas.SingleOrDefault(x => x.Version == version); 100 | 101 | return package != null; 102 | } 103 | 104 | public PackageMetadata Get(NuGetVersion version) 105 | { 106 | if (TryGet(version, out var metadata)) 107 | { 108 | return metadata; 109 | } 110 | 111 | throw new InvalidOperationException($"Could not find version {version}."); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/UpdatR/Summary.cs: -------------------------------------------------------------------------------- 1 | using NuGet.Versioning; 2 | using UpdatR.Internals; 3 | 4 | namespace UpdatR; 5 | 6 | public sealed class Summary( 7 | IDictionary<string, IEnumerable<string>> unknownPackages, 8 | IEnumerable<(string Name, string Source)> unauthorizedSources, 9 | IEnumerable<UpdatedPackage> updatedPackages, 10 | IEnumerable<DeprecatedPackage> deprecatedPackages, 11 | IEnumerable<VulnerablePackage> vulnerablePackages 12 | ) 13 | { 14 | private int? _updatedPackagesCount; 15 | 16 | public int UpdatedPackagesCount => _updatedPackagesCount ??= UpdatedPackages.Count(); 17 | public IEnumerable<UpdatedPackage> UpdatedPackages { get; } = updatedPackages; 18 | public IEnumerable<DeprecatedPackage> DeprecatedPackages { get; } = deprecatedPackages; 19 | public IEnumerable<VulnerablePackage> VulnerablePackages { get; } = vulnerablePackages; 20 | 21 | /// <summary> 22 | /// PackageId as key and projects and value. 23 | /// </summary> 24 | public IDictionary<string, IEnumerable<string>> UnknownPackages { get; } = unknownPackages; 25 | 26 | /// <summary> 27 | /// Sources that failed to use due to 401. 28 | /// </summary> 29 | public IEnumerable<(string Name, string Source)> UnauthorizedSources { get; } = 30 | unauthorizedSources; 31 | 32 | internal static Summary Create(Result result) 33 | { 34 | var updatedPackages = result 35 | .Projects.SelectMany(x => x.UpdatedPackages.Select(y => (Package: y, Project: x.Path))) 36 | .GroupBy(x => x.Package.PackageId) 37 | .Select(x => new UpdatedPackage( 38 | PackageId: x.Key, 39 | Updates: x.Select(y => (y.Package.From, y.Package.To, y.Project)) 40 | .OrderBy(x => x.Project) 41 | )); 42 | 43 | var deprecatedPackages = result 44 | .Projects.SelectMany(x => 45 | x.DeprecatedPackages.Select(y => (Package: y, Project: x.Path)) 46 | ) 47 | .GroupBy(x => x.Package.PackageId) 48 | .Select(x => (PackageId: x.Key, Versions: x.GroupBy(y => y.Package.Version))) 49 | .Select(x => 50 | ( 51 | x.PackageId, 52 | Versions: x.Versions.Select(y => 53 | ( 54 | y.Key, 55 | y.First().Package.DeprecationMetadata, 56 | Projects: y.Select(z => z.Project) 57 | ) 58 | ) 59 | ) 60 | ) 61 | .Select(x => new DeprecatedPackage( 62 | x.PackageId, 63 | x.Versions.Select(y => 64 | (new DeprecatedVersion(y.Key, y.DeprecationMetadata), y.Projects) 65 | ) 66 | )); 67 | 68 | var vulnerablePackages = result 69 | .Projects.SelectMany(x => 70 | x.VulnerablePackages.Select(y => (Package: y, Project: x.Path)) 71 | ) 72 | .GroupBy(x => x.Package.PackageId) 73 | .Select(x => (PackageId: x.Key, Versions: x.GroupBy(y => y.Package.Version))) 74 | .Select(x => 75 | ( 76 | x.PackageId, 77 | Versions: x.Versions.Select(y => 78 | ( 79 | y.Key, 80 | y.First().Package.Vulnerabilities, 81 | Projects: y.Select(z => z.Project) 82 | ) 83 | ) 84 | ) 85 | ) 86 | .Select(x => new VulnerablePackage( 87 | x.PackageId, 88 | x.Versions.Select(y => 89 | (new VulnerableVersion(y.Key, y.Vulnerabilities), y.Projects) 90 | ) 91 | )); 92 | 93 | return new Summary( 94 | result.UnknownPackages, 95 | result.UnauthorizedSources, 96 | updatedPackages, 97 | deprecatedPackages, 98 | vulnerablePackages 99 | ); 100 | } 101 | } 102 | 103 | public sealed record UpdatedPackage( 104 | string PackageId, 105 | IEnumerable<(NuGetVersion From, NuGetVersion To, string Project)> Updates 106 | ); 107 | 108 | public sealed record DeprecatedPackage( 109 | string PackageId, 110 | IEnumerable<(DeprecatedVersion Version, IEnumerable<string> Projects)> Versions 111 | ); 112 | 113 | public sealed record DeprecatedVersion( 114 | NuGetVersion NuGetVersion, 115 | PackageDeprecationMetadata DeprecationMetadata 116 | ); 117 | 118 | public sealed record VulnerablePackage( 119 | string PackageId, 120 | IEnumerable<(VulnerableVersion Version, IEnumerable<string> Projects)> Versions 121 | ); 122 | 123 | public sealed record VulnerableVersion( 124 | NuGetVersion Version, 125 | IEnumerable<PackageVulnerabilityMetadata> Vulnerabilities 126 | ); 127 | 128 | public sealed record PackageDeprecationMetadata( 129 | string? Message, 130 | IEnumerable<string> Reasons, 131 | AlternatePackageMetadata? AlternatePackage 132 | ); 133 | 134 | public sealed record AlternatePackageMetadata(string PackageId, VersionRange Range); 135 | 136 | public sealed record PackageVulnerabilityMetadata(Uri AdvisoryUrl, int Severity); 137 | -------------------------------------------------------------------------------- /tests/UpdatR.IntegrationTests/FileCreationUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | 3 | namespace UpdatR.IntegrationTests; 4 | 5 | internal static class FileCreationUtils 6 | { 7 | public static async Task<string> CreateSlnAsync( 8 | string path, 9 | string projectName, 10 | string projectPath 11 | ) 12 | { 13 | var content = GetResource("UpdatR.IntegrationTests.Resources.Templates.Dummy.sln"); 14 | 15 | content = content 16 | .Replace("<PROJECTNAME>", projectName) 17 | .Replace( 18 | "<PROJECTPATH>", 19 | Path.GetRelativePath(new FileInfo(path).DirectoryName!, projectPath) 20 | ); 21 | 22 | await File.WriteAllTextAsync(path, content); 23 | 24 | return await File.ReadAllTextAsync(path)!; 25 | } 26 | 27 | public static async Task<string> CreateToolsConfigAsync( 28 | string path, 29 | string packageId, 30 | string version, 31 | string command 32 | ) 33 | { 34 | var content = GetResource( 35 | "UpdatR.IntegrationTests.Resources.Templates..config.dotnet-tools.json" 36 | ); 37 | 38 | content = content 39 | .Replace("<PACKAGEID>", packageId) 40 | .Replace("<VERSION>", version) 41 | .Replace("<COMMAND>", command); 42 | 43 | await File.WriteAllTextAsync(path, content); 44 | 45 | return await File.ReadAllTextAsync(path)!; 46 | } 47 | 48 | // TODO: Generate json on-the-fly instead 49 | public static async Task<string> CreateToolsConfigAsync( 50 | string path, 51 | string packageId, 52 | string version, 53 | string command, 54 | string packageId2, 55 | string version2, 56 | string command2 57 | ) 58 | { 59 | var content = GetResource( 60 | "UpdatR.IntegrationTests.Resources.Templates..config.dotnet-tools2.json" 61 | ); 62 | 63 | content = content 64 | .Replace("<PACKAGEID>", packageId) 65 | .Replace("<VERSION>", version) 66 | .Replace("<COMMAND>", command); 67 | 68 | content = content 69 | .Replace("<PACKAGEID2>", packageId2) 70 | .Replace("<VERSION2>", version2) 71 | .Replace("<COMMAND2>", command2); 72 | 73 | await File.WriteAllTextAsync(path, content); 74 | 75 | return await File.ReadAllTextAsync(path)!; 76 | } 77 | 78 | public static void CreateNuGetConfig(string path, bool addNuGetOrg = false) 79 | { 80 | var nugetContent = GetResource("UpdatR.IntegrationTests.Resources.Templates.nuget.config"); 81 | 82 | var doc = XDocument.Parse(nugetContent); 83 | 84 | var packageSources = doc.Element("configuration")!.Element("packageSources")!; 85 | 86 | if (addNuGetOrg) 87 | { 88 | var nugetOrg = new XElement("add"); 89 | 90 | nugetOrg.Add( 91 | new XAttribute("key", "nuget.org"), 92 | new XAttribute("value", "https://api.nuget.org/v3/index.json") 93 | ); 94 | 95 | packageSources.Add(nugetOrg); 96 | } 97 | 98 | var local = new XElement("add"); 99 | 100 | local.Add( 101 | new XAttribute("key", "local"), 102 | new XAttribute("value", Paths.Temporary.Packages) 103 | ); 104 | 105 | packageSources.Add(local); 106 | 107 | doc.Save(path); 108 | } 109 | 110 | public static Task<string> CreateTempCsprojAsync( 111 | string path, 112 | params KeyValuePair<string, string>[] packages 113 | ) 114 | { 115 | return CreateTempCsprojAsync(path, "net6.0", packages); 116 | } 117 | 118 | public static async Task<string> CreateTempCsprojAsync( 119 | string path, 120 | string tfm = "net6.0", 121 | params KeyValuePair<string, string>[] packages 122 | ) 123 | { 124 | var csprojStr = GetResource("UpdatR.IntegrationTests.Resources.Templates.Dummy.App.csproj"); 125 | 126 | var csproj = XDocument.Parse(csprojStr); 127 | 128 | csproj 129 | .Element("Project")! 130 | .Element("PropertyGroup")! 131 | .Element("TargetFramework")! 132 | .SetValue(tfm); 133 | 134 | var itemGroup = csproj.Element("Project")!.Element("ItemGroup")!; 135 | 136 | foreach (var package in packages) 137 | { 138 | var packageReference = new XElement("PackageReference"); 139 | 140 | packageReference.Add( 141 | new XAttribute("Include", package.Key), 142 | new XAttribute("Version", package.Value) 143 | ); 144 | 145 | itemGroup.Add(packageReference); 146 | } 147 | 148 | csproj.Save(path); 149 | 150 | return await File.ReadAllTextAsync(path)!; 151 | } 152 | 153 | private static string GetResource(string resourceName) 154 | { 155 | using var stream = 156 | typeof(FileCreationUtils).Assembly.GetManifestResourceStream(resourceName) 157 | ?? throw new InvalidOperationException($"'{resourceName} is not an embedded resource."); 158 | 159 | using var reader = new StreamReader(stream); 160 | 161 | return reader.ReadToEnd(); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/UpdatR/Internals/Result.cs: -------------------------------------------------------------------------------- 1 | using NuGet.Versioning; 2 | 3 | namespace UpdatR.Internals; 4 | 5 | internal sealed class Result 6 | { 7 | private readonly List<(string Name, string Source)> _unauthorizedSources = []; 8 | private readonly Dictionary<string, HashSet<string>> _unknownPackages = new( 9 | StringComparer.OrdinalIgnoreCase 10 | ); 11 | private readonly string _rootPath; 12 | 13 | private Dictionary<string, ProjectWithPackages> _projects { get; } = 14 | new(StringComparer.OrdinalIgnoreCase); 15 | 16 | internal Result(string rootPath) 17 | { 18 | if (File.Exists(rootPath)) 19 | { 20 | _rootPath = new FileInfo(rootPath).DirectoryName!; 21 | } 22 | else if (Directory.Exists(rootPath)) 23 | { 24 | _rootPath = rootPath; 25 | } 26 | else 27 | { 28 | throw new ArgumentException("Root does not exist.", nameof(rootPath)); 29 | } 30 | } 31 | 32 | internal IDictionary<string, IEnumerable<string>> UnknownPackages => 33 | _unknownPackages.ToDictionary(x => x.Key, x => x.Value.AsEnumerable()); 34 | 35 | internal IEnumerable<ProjectWithPackages> Projects => _projects.Values; 36 | 37 | internal IEnumerable<(string Name, string Source)> UnauthorizedSources => _unauthorizedSources; 38 | 39 | internal bool TryAddProject(ProjectWithPackages project) 40 | { 41 | project = project with 42 | { 43 | Path = Path.GetRelativePath(_rootPath, project.Path) 44 | .Replace(Path.DirectorySeparatorChar, '\\'), 45 | }; 46 | 47 | foreach (var unknown in project.UnknownPackages) 48 | { 49 | TryAddUnknownPackage(unknown, project.Path); 50 | } 51 | 52 | if (_projects.ContainsKey(project.Path)) 53 | { 54 | return false; 55 | } 56 | else 57 | { 58 | _projects[project.Path] = project; 59 | 60 | return true; 61 | } 62 | } 63 | 64 | internal bool TryAddUnauthorizedSource(string name, string source) 65 | { 66 | if (_unauthorizedSources.Any(x => x.Name.Equals(name, StringComparison.Ordinal))) 67 | { 68 | return false; 69 | } 70 | else 71 | { 72 | _unauthorizedSources.Add((name, source)); 73 | 74 | return true; 75 | } 76 | } 77 | 78 | internal bool TryAddUnknownPackage(string packageId, string project) 79 | { 80 | if (_unknownPackages.TryGetValue(packageId, out var projects)) 81 | { 82 | projects.Add(project); 83 | } 84 | else 85 | { 86 | _unknownPackages[packageId] = [project]; 87 | } 88 | return true; 89 | } 90 | } 91 | 92 | internal sealed record ProjectWithPackages 93 | { 94 | private readonly HashSet<string> _unknownPackages = []; 95 | private readonly List<UpdatedPackage> _updatedPackages = []; 96 | private readonly List<DeprecatedPackage> _deprecatedPackages = []; 97 | private readonly List<VulnerablePackage> _vulnerablePackages = []; 98 | 99 | public string Path { get; init; } 100 | public IEnumerable<string> UnknownPackages => _unknownPackages; 101 | public IEnumerable<UpdatedPackage> UpdatedPackages => _updatedPackages; 102 | public IEnumerable<DeprecatedPackage> DeprecatedPackages => _deprecatedPackages; 103 | public IEnumerable<VulnerablePackage> VulnerablePackages => _vulnerablePackages; 104 | 105 | public ProjectWithPackages(string path) 106 | { 107 | Path = path; 108 | } 109 | 110 | public void AddUnknownPackage(string packageId) 111 | { 112 | _unknownPackages.Add(packageId); 113 | } 114 | 115 | public void AddUpdatedPackage(UpdatedPackage package) 116 | { 117 | _updatedPackages.Add(package); 118 | } 119 | 120 | public void AddDeprecatedPackage(DeprecatedPackage package) 121 | { 122 | _deprecatedPackages.Add(package); 123 | } 124 | 125 | public void AddVulnerablePackage(VulnerablePackage package) 126 | { 127 | _vulnerablePackages.Add(package); 128 | } 129 | 130 | public bool AnyPackages() => 131 | _updatedPackages.Count > 0 132 | || _deprecatedPackages.Count > 0 133 | || _vulnerablePackages.Count > 0; 134 | } 135 | 136 | internal sealed class UpdatedPackage(string packageId, NuGetVersion from, NuGetVersion to) 137 | { 138 | public string PackageId { get; } = packageId; 139 | public NuGetVersion From { get; } = from; 140 | public NuGetVersion To { get; } = to; 141 | } 142 | 143 | internal sealed class DeprecatedPackage( 144 | string packageId, 145 | NuGetVersion version, 146 | PackageDeprecationMetadata deprecationMetadata 147 | ) 148 | { 149 | public string PackageId { get; } = packageId; 150 | public NuGetVersion Version { get; } = version; 151 | public PackageDeprecationMetadata DeprecationMetadata { get; } = deprecationMetadata; 152 | } 153 | 154 | internal sealed class VulnerablePackage( 155 | string packageId, 156 | NuGetVersion version, 157 | IEnumerable<PackageVulnerabilityMetadata> vulnerabilities 158 | ) 159 | { 160 | public string PackageId { get; } = packageId; 161 | public NuGetVersion Version { get; } = version; 162 | public IEnumerable<PackageVulnerabilityMetadata> Vulnerabilities { get; } = vulnerabilities; 163 | } 164 | 165 | internal record PackageMetadata( 166 | NuGetVersion Version, 167 | IEnumerable<NuGet.Frameworks.NuGetFramework> TargetFrameworks, 168 | PackageDeprecationMetadata? DeprecationMetadata, 169 | IEnumerable<PackageVulnerabilityMetadata>? Vulnerabilities 170 | ); 171 | -------------------------------------------------------------------------------- /tests/UpdatR.E2eTests/LiveTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | using static SimpleExec.Command; 3 | 4 | namespace UpdatR.E2e; 5 | 6 | public sealed class LiveTests : IDisposable 7 | { 8 | private readonly TextWriter _originalConsoleOut; 9 | private readonly TestOutputHelperTextWriterAdapter _outAdapter; 10 | private bool disposedValue; 11 | 12 | public LiveTests(ITestOutputHelper output) 13 | { 14 | _originalConsoleOut = Console.Out; 15 | _outAdapter = new TestOutputHelperTextWriterAdapter(output); 16 | 17 | Console.SetOut(_outAdapter); 18 | } 19 | 20 | [Fact] 21 | public async Task UpdateDummyProject() 22 | { 23 | var runsOnGitHubActions = !string.IsNullOrWhiteSpace( 24 | Environment.GetEnvironmentVariable("GITHUB_ACTIONS") 25 | ); 26 | 27 | var root = await GetRepoRootDirectoryAsync(); 28 | 29 | Console.WriteLine("Root: " + root); 30 | 31 | var dummyProjectSrc = Path.Combine(root.FullName, "tests", "UpdatR.E2eTests", "Dummy"); 32 | 33 | if (!Directory.Exists(dummyProjectSrc)) 34 | { 35 | throw new InvalidOperationException($"Path {dummyProjectSrc} does not exist."); 36 | } 37 | 38 | var testTemp = Path.Combine(Path.GetTempPath(), "dotnet-updatr", "e2etests"); 39 | 40 | var dummyProject = Path.Combine(testTemp, "Dummy"); 41 | 42 | var log = Path.Combine(testTemp, "output.md"); 43 | var title = Path.Combine(testTemp, "title.md"); 44 | var description = Path.Combine(testTemp, "description.md"); 45 | 46 | if (Directory.Exists(dummyProject)) 47 | { 48 | Directory.Delete(dummyProject, true); 49 | } 50 | 51 | Directory.CreateDirectory(dummyProject); 52 | 53 | CopyDirectory(dummyProjectSrc, dummyProject, recursive: true); 54 | 55 | var cliProjectPath = Path.Combine(root.FullName, "src", "dotnet-updatr"); 56 | 57 | if (!runsOnGitHubActions) 58 | { 59 | await RunAsync( 60 | "dotnet", 61 | "build --configuration Release", 62 | workingDirectory: cliProjectPath 63 | ); 64 | } 65 | 66 | var cli = Path.Combine(cliProjectPath, "bin", "Release", "net6.0", "dotnet-updatr.dll"); 67 | 68 | await RunAsync( 69 | "dotnet", 70 | $"exec {cli} --output {log} --title {title} --description {description}", 71 | workingDirectory: dummyProject 72 | ); 73 | 74 | await Verify(GetVerifyObjects()); 75 | 76 | async IAsyncEnumerable<string> GetVerifyObjects() 77 | { 78 | yield return await File.ReadAllTextAsync(log)!; 79 | yield return await File.ReadAllTextAsync(title)!; 80 | yield return await File.ReadAllTextAsync(description)!; 81 | yield return await File.ReadAllTextAsync(Path.Combine(dummyProjectSrc, "Dummy.sln"))!; 82 | yield return await File.ReadAllTextAsync( 83 | Path.Combine(dummyProjectSrc, "Dummy.App", "Dummy.App.csproj") 84 | )!; 85 | yield return await File.ReadAllTextAsync( 86 | Path.Combine(dummyProjectSrc, "nuget.config") 87 | )!; 88 | yield return await File.ReadAllTextAsync(Path.Combine(dummyProject, "Dummy.sln"))!; 89 | yield return await File.ReadAllTextAsync( 90 | Path.Combine(dummyProject, "Dummy.App", "Dummy.App.csproj") 91 | )!; 92 | yield return await File.ReadAllTextAsync(Path.Combine(dummyProject, "nuget.config"))!; 93 | } 94 | } 95 | 96 | private static async Task<DirectoryInfo> GetRepoRootDirectoryAsync() 97 | { 98 | var (stdOutput, stdError) = await ReadAsync("git", "rev-parse --show-toplevel"); 99 | 100 | return new DirectoryInfo(stdOutput.Trim()); 101 | } 102 | 103 | private static void CopyDirectory(string sourceDir, string destinationDir, bool recursive) 104 | { 105 | var dir = new DirectoryInfo(sourceDir); 106 | 107 | if (!dir.Exists) 108 | { 109 | throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); 110 | } 111 | 112 | // Cache directories before we start copying 113 | DirectoryInfo[] dirs = dir.GetDirectories(); 114 | 115 | Directory.CreateDirectory(destinationDir); 116 | 117 | // Get the files in the source directory and copy to the destination directory 118 | foreach (FileInfo file in dir.GetFiles()) 119 | { 120 | string targetFilePath = Path.Combine(destinationDir, file.Name); 121 | file.CopyTo(targetFilePath); 122 | } 123 | 124 | // If recursive and copying subdirectories, recursively call this method 125 | if (recursive) 126 | { 127 | foreach (DirectoryInfo subDir in dirs) 128 | { 129 | string newDestinationDir = Path.Combine(destinationDir, subDir.Name); 130 | 131 | CopyDirectory(subDir.FullName, newDestinationDir, true); 132 | } 133 | } 134 | } 135 | 136 | private void Dispose(bool disposing) 137 | { 138 | if (!disposedValue) 139 | { 140 | if (disposing) 141 | { 142 | Console.SetOut(_originalConsoleOut); 143 | 144 | _outAdapter.Dispose(); 145 | } 146 | 147 | disposedValue = true; 148 | } 149 | } 150 | 151 | public void Dispose() 152 | { 153 | // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method 154 | Dispose(disposing: true); 155 | GC.SuppressFinalize(this); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # To learn more about .editorconfig see https://aka.ms/editorconfigdocs 2 | ############################### 3 | # Core EditorConfig Options # 4 | ############################### 5 | # All files 6 | [*] 7 | indent_style = space 8 | 9 | # XML project files 10 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] 11 | indent_size = 2 12 | 13 | # XML config files 14 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] 15 | indent_size = 2 16 | 17 | # Code files 18 | [*.{cs,csx,vb,vbx}] 19 | indent_size = 4 20 | insert_final_newline = true 21 | charset = utf-8-bom 22 | ############################### 23 | # .NET Coding Conventions # 24 | ############################### 25 | [*.{cs,vb}] 26 | # Organize usings 27 | dotnet_sort_system_directives_first = true 28 | # this. preferences 29 | dotnet_style_qualification_for_field = false:silent 30 | dotnet_style_qualification_for_property = false:silent 31 | dotnet_style_qualification_for_method = false:silent 32 | dotnet_style_qualification_for_event = false:silent 33 | # Language keywords vs BCL types preferences 34 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent 35 | dotnet_style_predefined_type_for_member_access = true:silent 36 | # Parentheses preferences 37 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent 38 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent 39 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent 40 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent 41 | # Modifier preferences 42 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent 43 | dotnet_style_readonly_field = true:suggestion 44 | # Expression-level preferences 45 | dotnet_style_object_initializer = true:suggestion 46 | dotnet_style_collection_initializer = true:suggestion 47 | dotnet_style_explicit_tuple_names = true:suggestion 48 | dotnet_style_null_propagation = true:suggestion 49 | dotnet_style_coalesce_expression = true:suggestion 50 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent 51 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 52 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 53 | dotnet_style_prefer_auto_properties = true:silent 54 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent 55 | dotnet_style_prefer_conditional_expression_over_return = true:silent 56 | ############################### 57 | # Naming Conventions # 58 | ############################### 59 | # Style Definitions 60 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 61 | # Use PascalCase for constant fields 62 | dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion 63 | dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields 64 | dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style 65 | dotnet_naming_symbols.constant_fields.applicable_kinds = field 66 | dotnet_naming_symbols.constant_fields.applicable_accessibilities = * 67 | dotnet_naming_symbols.constant_fields.required_modifiers = const 68 | ############################### 69 | # C# Coding Conventions # 70 | ############################### 71 | [*.cs] 72 | # var preferences 73 | csharp_style_var_for_built_in_types = true:silent 74 | csharp_style_var_when_type_is_apparent = true:silent 75 | csharp_style_var_elsewhere = true:silent 76 | # Expression-bodied members 77 | csharp_style_expression_bodied_methods = false:silent 78 | csharp_style_expression_bodied_constructors = false:silent 79 | csharp_style_expression_bodied_operators = false:silent 80 | csharp_style_expression_bodied_properties = true:silent 81 | csharp_style_expression_bodied_indexers = true:silent 82 | csharp_style_expression_bodied_accessors = true:silent 83 | # Pattern matching preferences 84 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 85 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 86 | # Null-checking preferences 87 | csharp_style_throw_expression = true:suggestion 88 | csharp_style_conditional_delegate_call = true:suggestion 89 | # Modifier preferences 90 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion 91 | # Expression-level preferences 92 | csharp_prefer_braces = true:silent 93 | csharp_style_deconstructed_variable_declaration = true:suggestion 94 | csharp_prefer_simple_default_expression = true:suggestion 95 | csharp_style_pattern_local_over_anonymous_function = true:suggestion 96 | csharp_style_inlined_variable_declaration = true:suggestion 97 | ############################### 98 | # C# Formatting Rules # 99 | ############################### 100 | # New line preferences 101 | csharp_new_line_before_open_brace = all 102 | csharp_new_line_before_else = true 103 | csharp_new_line_before_catch = true 104 | csharp_new_line_before_finally = true 105 | csharp_new_line_before_members_in_object_initializers = true 106 | csharp_new_line_before_members_in_anonymous_types = true 107 | csharp_new_line_between_query_expression_clauses = true 108 | # Indentation preferences 109 | csharp_indent_case_contents = true 110 | csharp_indent_switch_labels = true 111 | csharp_indent_labels = flush_left 112 | # Space preferences 113 | csharp_space_after_cast = false 114 | csharp_space_after_keywords_in_control_flow_statements = true 115 | csharp_space_between_method_call_parameter_list_parentheses = false 116 | csharp_space_between_method_declaration_parameter_list_parentheses = false 117 | csharp_space_between_parentheses = false 118 | csharp_space_before_colon_in_inheritance_clause = true 119 | csharp_space_after_colon_in_inheritance_clause = true 120 | csharp_space_around_binary_operators = before_and_after 121 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 122 | csharp_space_between_method_call_name_and_opening_parenthesis = false 123 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 124 | # Wrapping preferences 125 | csharp_preserve_single_line_statements = true 126 | csharp_preserve_single_line_blocks = true 127 | ############################### 128 | # VB Coding Conventions # 129 | ############################### 130 | [*.vb] 131 | # Modifier preferences 132 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion 133 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | <!-- 2 | GENERATED FILE - DO NOT EDIT 3 | This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets). 4 | Source File: /mdsource/README.source.md 5 | To change this file edit the source file and then run MarkdownSnippets. 6 | --> 7 | 8 | [![build](https://github.com/OskarKlintrot/UpdatR/actions/workflows/build.yml/badge.svg)](https://github.com/OskarKlintrot/UpdatR/actions/workflows/build.yml)<!-- singleLineInclude: header. path: /mdsource/header.include.md --> 9 | 10 | # UpdatR packages 11 | 12 | ## dotnet-updatr<!-- include: cli-readme. path: /mdsource/cli-readme.include.md --> 13 | 14 | [![Latest Nuget Version](https://badgen.net/nuget/v/dotnet-updatr/latest)](https://www.nuget.org/packages/dotnet-updatr/) 15 | [![Latest Nuget Version](https://badgen.net/nuget/dt/dotnet-updatr)](https://www.nuget.org/packages/dotnet-updatr/) 16 | 17 | Dotnet tool for updating package reference and dotnet-tools.json. 18 | 19 | The tool will try to stick to package versions that is supported by the projects target framework moniker. If a package supports both .NETStandard and .NET, the compatibility with .NETStandard will be ignored if the project is targeting .NET. This is to avoid false positives where a package technically supports a TFM but in reality never have been tested against the TFM. 20 | 21 | See [UpdatR](#updatr) for SDK. 22 | 23 | ### Installation 24 | 25 | ``` 26 | > dotnet tool install --global dotnet-updatr 27 | ``` 28 | 29 | ### Basic Usage 30 | 31 | To update all `*.csproj` and `dotnet-tools.json` recursively: 32 | 33 | ``` 34 | > update 35 | ``` 36 | 37 | If you only want to update the `*.csproj` and `dotnet-tools.json` that is part of a solution you can specify the solution directly: 38 | 39 | ``` 40 | > update path/to/solution.sln 41 | ``` 42 | 43 | You can also update a single `*.csproj` or `dotnet-config.json`: 44 | 45 | ``` 46 | > update path/to/example.csproj 47 | ``` 48 | 49 | If you want to preview the result you can do a dry run: 50 | 51 | ``` 52 | > update --dry-run 53 | ``` 54 | 55 | For larger solutions with multiple packages the console output is not optimal. You can choose to view the result in your default browser instead: 56 | 57 | ``` 58 | > update --browser 59 | ``` 60 | 61 | To allow packages to be updated to prerelease versions use the `--prerelease` options: 62 | 63 | ``` 64 | > update --prerelease 65 | ``` 66 | 67 | To update only one or more specific packages you can use the `--package` option: 68 | 69 | ``` 70 | > update --package Microsoft.* --package Newtonsoft.* 71 | ``` 72 | 73 | If you don't want to update a package or packages you can exclude them: 74 | 75 | ``` 76 | > update --exclude-package Microsoft.* --exclude-package Newtonsoft.* 77 | ``` 78 | 79 | If UpdatR fails to find the correct lowest TFM to support, for example for projects that supports multiple TFM's, then it's possible to set the TFM manually: 80 | 81 | ``` 82 | > update --tfm net6.0 83 | ``` 84 | 85 | ### As part of CI/CD 86 | 87 | You can get the output as a markdown by setting a path for the output: 88 | 89 | ``` 90 | > update --output path/to/output/folder 91 | ``` 92 | 93 | It's possible to get the title and the rest of the output as separate .md-files which is helpful when creating a pull request: 94 | 95 | ``` 96 | > update --title path/to/title.md --description path/to/description.md 97 | ``` 98 | 99 | then you can use `title.md` as the title for your pull request and `description.md` as the body. 100 | 101 | UpdatR is used to update it's own dependencies, have a look at [Build.cs](https://github.com/OskarKlintrot/UpdatR/blob/main/tools/Build/Build.cs) for an example that uses [Bullseye](https://www.nuget.org/packages/Bullseye) and [SimpleExec](https://www.nuget.org/packages/SimpleExec). However, if you are using C# in your CI/CD pipeline it's probably easier to just use [UpdatR](#updatr) directly instead. That's the package that powers `dotnet-updatr` under the hood. 102 | 103 | ### All options 104 | 105 | <!-- snippet: cli-usage.txt --> 106 | ```txt 107 | Usage: 108 | update [<args>] [options] 109 | 110 | Arguments: 111 | <args> Path to solution or project(s). Defaults to current folder. Target can be a specific file or folder. If target is a folder then all *.csproj-files and dotnet-config.json-files will be processed. [default: .] 112 | 113 | Options: 114 | --package <package> Package to update. Supports * as wildcard. Will update all unless specified. [] 115 | --exclude-package <exclude-package> Package to exclude. Supports * as wildcard. [] 116 | --output <output> Defaults to "output.md". Explicitly set to fileName.txt to generate plain text instead of markdown. [] 117 | --title <title> Outputs title to path. [] 118 | --description <description> Outputs description to path. [] 119 | --verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Log level. [default: Warning] 120 | --dry-run Do not save any changes. [default: False] 121 | --prerelease Allow prerelease packages to be installed. [default: False] 122 | --browser Open summary in browser. [default: False] 123 | --interactive Interaction with user is possible. [default: False] 124 | --tfm <tfm> Lowest TFM to support. [] 125 | --version Show version information 126 | -?, -h, --help Show help and usage information 127 | ``` 128 | <!-- endSnippet --> 129 | <!-- endInclude --> 130 | 131 | ## UpdatR<!-- include: sdk-readme. path: /mdsource/sdk-readme.include.md --> 132 | 133 | [![Latest Nuget Version](https://badgen.net/nuget/v/UpdatR/latest)](https://www.nuget.org/packages/UpdatR/) 134 | [![Latest Nuget Version](https://badgen.net/nuget/dt/UpdatR)](https://www.nuget.org/packages/UpdatR/) 135 | 136 | NuGet package to programmatically update package reference and dotnet-tools.json. 137 | 138 | The tool will try to stick to package versions that is supported by the projects target framework moniker. If a package supports both .NETStandard and .NET, the compatibility with .NETStandard will be ignored if the project is targeting .NET. This is to avoid false positives where a package technically supports a TFM but in reality never have been tested against the TFM. 139 | 140 | See [dotnet-updatr](#dotnet-updatr) for a dotnet tool that can be run from the command-line. 141 | 142 | ### Usage 143 | 144 | <!-- snippet: SampleUsage --> 145 | ```cs 146 | using UpdatR; 147 | using UpdatR.Formatters; 148 | 149 | var updatr = new Updater(); // Can take an ILogger 150 | 151 | var summary = await updatr.UpdateAsync("path"); 152 | 153 | if (summary.UpdatedPackagesCount == 0) // No packages where updated 154 | { 155 | return; 156 | } 157 | 158 | var title = MarkdownFormatter.GenerateTitle(summary); 159 | 160 | var description = 161 | "# PR created automatically by UpdatR" 162 | + Environment.NewLine 163 | + Environment.NewLine 164 | + MarkdownFormatter.GenerateDescription(summary); 165 | 166 | // Use title as title in the PR and description as the description/body in the PR 167 | ``` 168 | <!-- endSnippet --> 169 | <!-- endInclude --> 170 | 171 | # Icon<!-- include: footer. path: /mdsource/footer.include.md --> 172 | Package by Sergey Novosyolov from [NounProject.com](http://NounProject.com)<!-- endInclude --> 173 | -------------------------------------------------------------------------------- /src/UpdatR/Domain/RootDir.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | using NuGet.Packaging; 3 | 4 | namespace UpdatR.Domain; 5 | 6 | internal sealed class RootDir 7 | { 8 | private readonly DirectoryInfo _path; 9 | 10 | private RootDir(DirectoryInfo path) 11 | { 12 | _path = path; 13 | } 14 | 15 | public string Path => _path.FullName; 16 | 17 | public ICollection<DotnetTools>? DotnetTools { get; private set; } 18 | 19 | public ICollection<Csproj>? Csprojs { get; private set; } 20 | 21 | public void AddDotnetTools(DotnetTools dotnetTools) 22 | { 23 | (DotnetTools ??= []).Add(dotnetTools); 24 | } 25 | 26 | public void AddCsproj(Csproj csproj) 27 | { 28 | (Csprojs ??= []).Add(csproj); 29 | } 30 | 31 | public static RootDir Create(string path) 32 | { 33 | if (string.IsNullOrWhiteSpace(path)) 34 | { 35 | throw new ArgumentException( 36 | $"'{nameof(path)}' cannot be null or whitespace.", 37 | nameof(path) 38 | ); 39 | } 40 | 41 | if (!Directory.Exists(path) && !File.Exists(path)) 42 | { 43 | throw new ArgumentException($"'{nameof(path)}' does not exist.", nameof(path)); 44 | } 45 | 46 | path = System.IO.Path.GetFullPath(path); 47 | 48 | return File.GetAttributes(path).HasFlag(FileAttributes.Directory) switch 49 | { 50 | true => CreateFromFolder(new DirectoryInfo(path)), 51 | false => CreateFromFile(new FileInfo(path)), 52 | }; 53 | } 54 | 55 | private static RootDir CreateFromFolder(DirectoryInfo path) 56 | { 57 | var dir = new RootDir(path); 58 | 59 | foreach ( 60 | var projectFile in Directory.EnumerateFiles( 61 | path.FullName, 62 | "*.csproj", 63 | new EnumerationOptions 64 | { 65 | MatchCasing = MatchCasing.CaseInsensitive, 66 | RecurseSubdirectories = true, 67 | } 68 | ) 69 | ) 70 | { 71 | var csproj = Csproj.Create(projectFile); 72 | 73 | dir.AddCsproj(csproj); 74 | } 75 | 76 | foreach ( 77 | var configFile in Directory.EnumerateFiles( 78 | path.FullName, 79 | "dotnet-tools.json", 80 | new EnumerationOptions 81 | { 82 | MatchCasing = MatchCasing.CaseInsensitive, 83 | RecurseSubdirectories = true, 84 | AttributesToSkip = FileAttributes.System, 85 | } 86 | ) 87 | ) 88 | { 89 | var config = Domain.DotnetTools.Create( 90 | configFile, 91 | dir.Csprojs ?? GetProjectsRecursiveFromParent(path) 92 | ); 93 | 94 | dir.AddDotnetTools(config); 95 | } 96 | 97 | if (dir.Csprojs is null && dir.DotnetTools is null) 98 | { 99 | throw new ArgumentException( 100 | "Path contains no .csproj files or dotnet-tools.json files.", 101 | nameof(path) 102 | ); 103 | } 104 | 105 | return dir; 106 | } 107 | 108 | private static RootDir CreateFromFile(FileInfo path) 109 | { 110 | if (path.Extension.Equals(".sln", StringComparison.OrdinalIgnoreCase)) 111 | { 112 | var dir = new RootDir(path.Directory!); 113 | 114 | foreach (var csproj in GetProjectsFromSolution(path)) 115 | { 116 | dir.AddCsproj(csproj); 117 | } 118 | 119 | AddDotnetToolsFromCsproj(dir); 120 | 121 | foreach (var item in GetDotnetToolsConfigFromSolution(path, dir.Csprojs ?? [])) 122 | { 123 | dir.AddDotnetTools(item); 124 | } 125 | 126 | return dir; 127 | } 128 | 129 | if (path.Extension.Equals(".csproj", StringComparison.OrdinalIgnoreCase)) 130 | { 131 | var dir = new RootDir(path.Directory!); 132 | 133 | dir.AddCsproj(Csproj.Create(path.FullName)); 134 | 135 | AddDotnetToolsFromCsproj(dir); 136 | 137 | return dir; 138 | } 139 | 140 | if (path.Name.Equals("dotnet-tools.json", StringComparison.OrdinalIgnoreCase)) 141 | { 142 | var projects = GetProjectsRecursiveFromParent(path.Directory!); 143 | 144 | var dir = new RootDir(path.Directory!); 145 | 146 | dir.AddDotnetTools(Domain.DotnetTools.Create(path.FullName, projects)); 147 | 148 | return dir; 149 | } 150 | 151 | throw new ArgumentException($"'{nameof(path)}' is not a supported file.", nameof(path)); 152 | 153 | static void AddDotnetToolsFromCsproj(RootDir dir) 154 | { 155 | foreach (var csproj in dir.Csprojs ?? Array.Empty<Csproj>()) 156 | { 157 | var configPath = System.IO.Path.Combine( 158 | csproj.Parent, 159 | ".config", 160 | "dotnet-tools.json" 161 | ); 162 | 163 | if (!File.Exists(configPath)) 164 | { 165 | continue; 166 | } 167 | 168 | dir.AddDotnetTools(Domain.DotnetTools.Create(configPath, dir.Csprojs ?? [])); 169 | } 170 | } 171 | } 172 | 173 | private static HashSet<Csproj> GetProjectsRecursiveFromParent(DirectoryInfo path) 174 | { 175 | var isInConfigFolder = path.Name.Equals(".config", StringComparison.OrdinalIgnoreCase); 176 | 177 | HashSet<Csproj> projects = []; 178 | 179 | if (isInConfigFolder) 180 | { 181 | projects.AddRange( 182 | Directory 183 | .EnumerateFiles( 184 | path.Parent!.FullName, 185 | "*.csproj", 186 | new EnumerationOptions 187 | { 188 | MatchCasing = MatchCasing.CaseInsensitive, 189 | RecurseSubdirectories = true, 190 | } 191 | ) 192 | .Select(Csproj.Create) 193 | ); 194 | } 195 | 196 | return projects; 197 | } 198 | 199 | private static IEnumerable<Csproj> GetProjectsFromSolution(FileInfo solution) => 200 | Regex 201 | .Matches( 202 | File.ReadAllText(solution.FullName), 203 | @"(Project).*(?<="")(?<Project>\S*\.csproj)(?="")", 204 | RegexOptions.Multiline 205 | ) 206 | .Select(x => System.IO.Path.Combine(x.Groups["Project"].Value.Split('\\'))) // sln has windows-style paths, will not work on linux 207 | .Select(x => System.IO.Path.Combine(solution.DirectoryName!, x)) 208 | .Select(x => new FileInfo(x)) 209 | .Where(x => x.Exists) 210 | .Select(x => Csproj.Create(x.FullName)); 211 | 212 | private static IEnumerable<DotnetTools> GetDotnetToolsConfigFromSolution( 213 | FileInfo solution, 214 | IEnumerable<Csproj> csprojs 215 | ) => 216 | Regex 217 | .Matches( 218 | File.ReadAllText(solution.FullName), 219 | """(?<File>\.config\\dotnet-tools\.json)(?= =)""", 220 | RegexOptions.Multiline 221 | ) 222 | .Select(x => System.IO.Path.Combine(x.Groups["File"].Value)) 223 | .Select(x => System.IO.Path.Combine(solution.DirectoryName!, x)) 224 | .Select(x => new FileInfo(x)) 225 | .Where(x => x.Exists) 226 | .Select(x => Domain.DotnetTools.Create(x.FullName, csprojs)); 227 | } 228 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | 352 | # Verify 353 | *.received.* 354 | *.verified.*.bak 355 | 356 | # Packages for integration testing 357 | !*/UpdatR.IntegrationTests/Resources/Packages/**/* 358 | -------------------------------------------------------------------------------- /src/dotnet-updatr/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Globalization; 3 | using System.Runtime.InteropServices; 4 | using BuildingBlocks; 5 | using Markdig; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Logging; 8 | using UpdatR.Formatters; 9 | 10 | namespace UpdatR.Cli; 11 | 12 | internal static partial class Program 13 | { 14 | private static ILogger _logger = null!; 15 | 16 | /// <summary> 17 | /// Update all packages in solution or project(s). 18 | /// </summary> 19 | /// <param name="args">Path to solution or project(s). Defaults to current folder. Target can be a specific file or folder. If target is a folder then all *.csproj-files and dotnet-config.json-files will be processed.</param> 20 | /// <param name="package">Package to update. Supports * as wildcard. Will update all unless specified.</param> 21 | /// <param name="excludePackage">Package to exclude. Supports * as wildcard.</param> 22 | /// <param name="output">Defaults to "output.md". Explicitly set to fileName.txt to generate plain text instead of markdown.</param> 23 | /// <param name="title">Outputs title to path.</param> 24 | /// <param name="description">Outputs description to path.</param> 25 | /// <param name="verbosity">Log level.</param> 26 | /// <param name="dryRun">Do not save any changes.</param> 27 | /// <param name="prerelease">Allow prerelease packages to be installed.</param> 28 | /// <param name="browser">Open summary in browser.</param> 29 | /// <param name="interactive">Interaction with user is possible.</param> 30 | /// <param name="tfm">Lowest TFM to support.</param> 31 | /// <returns></returns> 32 | /// <exception cref="ArgumentException"></exception> 33 | internal static async Task Main( 34 | string? args = ".", 35 | string[]? package = null, 36 | string[]? excludePackage = null, 37 | string? output = null, 38 | string? title = null, 39 | string? description = null, 40 | LogLevel verbosity = LogLevel.Warning, 41 | bool dryRun = false, 42 | bool prerelease = false, 43 | bool browser = false, 44 | bool interactive = false, 45 | string? tfm = null 46 | ) 47 | { 48 | var sw = Stopwatch.StartNew(); 49 | 50 | var services = new ServiceCollection() 51 | .AddTransient<Updater>() 52 | .AddLogging(builder => 53 | { 54 | builder.SetMinimumLevel(verbosity); 55 | builder.AddConsole(); 56 | }) 57 | .BuildServiceProvider(); 58 | 59 | _logger = services.GetRequiredService<ILoggerFactory>().CreateLogger(nameof(Program)); 60 | 61 | var update = services.GetRequiredService<Updater>(); 62 | 63 | var summary = await update.UpdateAsync( 64 | path: args, 65 | excludePackages: excludePackage, 66 | packages: package, 67 | dryRun: dryRun, 68 | prerelease: prerelease, 69 | interactive: interactive, 70 | targetFrameworkMoniker: tfm 71 | ); 72 | 73 | var outputStr = TextFormatter.PlainText(summary); 74 | 75 | if (browser) 76 | { 77 | var outputMd = MarkdownFormatter.Generate(summary); 78 | 79 | var htmlPath = Paths.Temporary; 80 | 81 | Directory.CreateDirectory(htmlPath); 82 | 83 | var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); 84 | var html = Markdown.ToHtml(outputMd, pipeline); 85 | 86 | var filePath = Path.Combine(htmlPath, "summary.html"); 87 | 88 | await File.WriteAllTextAsync(filePath, html); 89 | 90 | OpenFile(filePath); 91 | } 92 | else 93 | { 94 | WriteSummaryToConsole(outputStr); 95 | } 96 | 97 | if (output is not null) 98 | { 99 | if (string.IsNullOrWhiteSpace(new FileInfo(output).Extension)) 100 | { 101 | await File.WriteAllTextAsync( 102 | Path.Combine(output, "output.md"), 103 | MarkdownFormatter.Generate(summary) 104 | ); 105 | } 106 | else 107 | { 108 | outputStr = new FileInfo(output).Extension switch 109 | { 110 | ".txt" => outputStr, 111 | ".md" => MarkdownFormatter.Generate(summary), 112 | _ => throw new NotImplementedException(), 113 | }; 114 | 115 | await File.WriteAllTextAsync(output, outputStr); 116 | } 117 | } 118 | 119 | if (title is not null) 120 | { 121 | if (string.IsNullOrWhiteSpace(new FileInfo(title).Extension)) 122 | { 123 | await File.WriteAllTextAsync( 124 | Path.Combine(title, "title.md"), 125 | MarkdownFormatter.GenerateTitle(summary) 126 | ); 127 | } 128 | else if ( 129 | new FileInfo(title).Extension.Equals(".md", StringComparison.OrdinalIgnoreCase) 130 | ) 131 | { 132 | await File.WriteAllTextAsync(title, MarkdownFormatter.GenerateTitle(summary)); 133 | } 134 | else 135 | { 136 | throw new InvalidOperationException( 137 | "Unsupported file extension. Only .md is supported." 138 | ); 139 | } 140 | } 141 | 142 | if (description is not null) 143 | { 144 | if (string.IsNullOrWhiteSpace(new FileInfo(description).Extension)) 145 | { 146 | await File.WriteAllTextAsync( 147 | Path.Combine(description, "description.md"), 148 | MarkdownFormatter.GenerateDescription(summary) 149 | ); 150 | } 151 | else if ( 152 | new FileInfo(description).Extension.Equals( 153 | ".md", 154 | StringComparison.OrdinalIgnoreCase 155 | ) 156 | ) 157 | { 158 | await File.WriteAllTextAsync( 159 | description, 160 | MarkdownFormatter.GenerateDescription(summary) 161 | ); 162 | } 163 | else 164 | { 165 | throw new InvalidOperationException( 166 | "Unsupported file extension. Only .md is supported." 167 | ); 168 | } 169 | } 170 | 171 | LogFinished(_logger, sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff", new CultureInfo("en-US"))); 172 | } 173 | 174 | private static void WriteSummaryToConsole(string summary) 175 | { 176 | var output = summary.Split(Environment.NewLine); 177 | 178 | for (int i = 0; i < output.Length; i++) 179 | { 180 | if (i is >= 0 and <= 2) 181 | { 182 | Console.ForegroundColor = ConsoleColor.Green; 183 | } 184 | else 185 | { 186 | Console.ResetColor(); 187 | } 188 | 189 | Console.WriteLine(output[i]); 190 | } 191 | } 192 | 193 | private static void OpenFile(string path) 194 | { 195 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 196 | { 197 | Process.Start("cmd.exe ", "/c " + path); 198 | } 199 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 200 | { 201 | Process.Start("xdg-open", path); 202 | } 203 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) 204 | { 205 | Process.Start("open", path); 206 | } 207 | } 208 | 209 | [LoggerMessage(Level = LogLevel.Information, Message = "Finished after {ElapsedTime}.")] 210 | static partial void LogFinished(ILogger logger, string elapsedTime); 211 | } 212 | -------------------------------------------------------------------------------- /tests/UpdatR.UnitTests/Domain/NuGetPackageTests.cs: -------------------------------------------------------------------------------- 1 | using NuGet.Frameworks; 2 | using NuGet.Versioning; 3 | using UpdatR.Domain; 4 | using UpdatR.Internals; 5 | 6 | namespace UpdatR.UnitTests.Domain; 7 | 8 | public class NuGetPackageTests 9 | { 10 | [Theory] 11 | [InlineData("0.0.1", false, "1.0.0")] 12 | [InlineData("0.0.1", true, "1.1.0-beta0")] 13 | [InlineData("1.0.0", false)] 14 | [InlineData("1.0.0", true, "1.1.0-beta0")] 15 | public void TryGetLatestComparedTo( 16 | string comparedTo, 17 | bool usePrerelease, 18 | string? expectedNewResult = null 19 | ) 20 | { 21 | // Arrange 22 | var package = new NuGetPackage( 23 | "package-id", 24 | [ 25 | new PackageMetadata( 26 | NuGetVersion.Parse("0.0.1"), 27 | [NuGetFramework.Parse("net5.0"), NuGetFramework.Parse("net6.0")], 28 | null, 29 | null 30 | ), 31 | new PackageMetadata( 32 | NuGetVersion.Parse("1.0.0"), 33 | [NuGetFramework.Parse("net6.0")], 34 | null, 35 | null 36 | ), 37 | new PackageMetadata( 38 | NuGetVersion.Parse("1.1.0-beta0"), 39 | [NuGetFramework.Parse("net6.0")], 40 | null, 41 | null 42 | ), 43 | new PackageMetadata( 44 | NuGetVersion.Parse("2.0.0"), 45 | [NuGetFramework.Parse("net7.0")], 46 | null, 47 | null 48 | ), 49 | ] 50 | ); 51 | 52 | // Act 53 | var newerVersionIsAvailable = package.TryGetLatestComparedTo( 54 | version: NuGetVersion.Parse(comparedTo), 55 | targetFramework: NuGetFramework.Parse("net6.0"), 56 | usePrerelease: usePrerelease, 57 | package: out var packageMetadata 58 | ); 59 | 60 | // Assert 61 | if (expectedNewResult is null) 62 | { 63 | Assert.False(newerVersionIsAvailable); 64 | } 65 | else 66 | { 67 | Assert.True(newerVersionIsAvailable); 68 | Assert.Equal(expectedNewResult, packageMetadata?.Version.ToString()); 69 | } 70 | } 71 | 72 | [Theory] 73 | [InlineData("net6.0", "2.0.0")] 74 | [InlineData("net7.0", "2.0.0")] 75 | [InlineData("net9.0", "2.0.0")] 76 | [InlineData("netstandard2.0", "2.0.0")] 77 | [System.Diagnostics.CodeAnalysis.SuppressMessage( 78 | "Naming", 79 | "CA1707:Identifiers should not contain underscores", 80 | Justification = "Test name" 81 | )] 82 | public void TryGetLatestComparedTo_NetStandard_OnlySupport(string tfm, string? expected = null) 83 | { 84 | // Arrange 85 | var package = new NuGetPackage( 86 | "package-id", 87 | [ 88 | new PackageMetadata( 89 | NuGetVersion.Parse("1.0.0"), 90 | [NuGetFramework.Parse("netstandard2.0")], 91 | null, 92 | null 93 | ), 94 | new PackageMetadata( 95 | NuGetVersion.Parse("2.0.0"), 96 | [NuGetFramework.Parse("netstandard2.0")], 97 | null, 98 | null 99 | ), 100 | ] 101 | ); 102 | 103 | // Act 104 | var newerVersionIsAvailable = package.TryGetLatestComparedTo( 105 | version: NuGetVersion.Parse("1.0.0"), 106 | targetFramework: NuGetFramework.Parse(tfm), 107 | usePrerelease: false, 108 | package: out var packageMetadata 109 | ); 110 | 111 | // Assert 112 | if (expected is null) 113 | { 114 | Assert.False(newerVersionIsAvailable); 115 | } 116 | else 117 | { 118 | Assert.True(newerVersionIsAvailable); 119 | Assert.Equal(expected, packageMetadata?.Version.ToString()); 120 | } 121 | } 122 | 123 | [Theory] 124 | [InlineData("net9.0", "3.0.0")] 125 | [System.Diagnostics.CodeAnalysis.SuppressMessage( 126 | "Naming", 127 | "CA1707:Identifiers should not contain underscores", 128 | Justification = "Test name" 129 | )] 130 | public void TryGetLatestComparedTo_HtmlAgilityPack(string tfm, string? expected = null) 131 | { 132 | // Arrange 133 | var package = new NuGetPackage( 134 | "package-id", 135 | [ 136 | new PackageMetadata( 137 | NuGetVersion.Parse("3.0.0"), 138 | [ 139 | NuGetFramework.Parse("netstandard1.3"), 140 | NuGetFramework.Parse("v4.0"), 141 | NuGetFramework.Parse("v4.5"), 142 | NuGetFramework.Parse("netstandard1.6"), 143 | NuGetFramework.Parse("netstandard2.0"), 144 | ], 145 | null, 146 | null 147 | ), 148 | ] 149 | ); 150 | 151 | // Act 152 | var newerVersionIsAvailable = package.TryGetLatestComparedTo( 153 | version: NuGetVersion.Parse("1.0.0"), 154 | targetFramework: NuGetFramework.Parse(tfm), 155 | usePrerelease: false, 156 | package: out var packageMetadata 157 | ); 158 | 159 | // Assert 160 | if (expected is null) 161 | { 162 | Assert.False(newerVersionIsAvailable); 163 | } 164 | else 165 | { 166 | Assert.True(newerVersionIsAvailable); 167 | Assert.Equal(expected, packageMetadata?.Version.ToString()); 168 | } 169 | } 170 | 171 | [Theory] 172 | [InlineData("net6.0")] 173 | [InlineData("net7.0", "2.0.0")] 174 | [InlineData("net9.0", "3.0.0")] 175 | [InlineData("netstandard2.0", "3.0.0")] 176 | [System.Diagnostics.CodeAnalysis.SuppressMessage( 177 | "Naming", 178 | "CA1707:Identifiers should not contain underscores", 179 | Justification = "Test name" 180 | )] 181 | public void TryGetLatestComparedTo_Ignore_NetStandard(string tfm, string? expected = null) 182 | { 183 | // Arrange 184 | var package = new NuGetPackage( 185 | "package-id", 186 | [ 187 | new PackageMetadata( 188 | NuGetVersion.Parse("1.0.0"), 189 | [ 190 | NuGetFramework.Parse("netstandard2.0"), 191 | NuGetFramework.Parse("net6.0"), 192 | NuGetFramework.Parse("net7.0"), 193 | ], 194 | null, 195 | null 196 | ), 197 | new PackageMetadata( 198 | NuGetVersion.Parse("2.0.0"), 199 | [ 200 | NuGetFramework.Parse("netstandard2.0"), 201 | NuGetFramework.Parse("net7.0"), 202 | NuGetFramework.Parse("net8.0"), 203 | ], 204 | null, 205 | null 206 | ), 207 | new PackageMetadata( 208 | NuGetVersion.Parse("3.0.0"), 209 | [NuGetFramework.Parse("netstandard2.0"), NuGetFramework.Parse("net9.0")], 210 | null, 211 | null 212 | ), 213 | ] 214 | ); 215 | 216 | // Act 217 | var newerVersionIsAvailable = package.TryGetLatestComparedTo( 218 | version: NuGetVersion.Parse("1.0.0"), 219 | targetFramework: NuGetFramework.Parse(tfm), 220 | usePrerelease: false, 221 | package: out var packageMetadata 222 | ); 223 | 224 | // Assert 225 | if (expected is null) 226 | { 227 | Assert.False(newerVersionIsAvailable); 228 | } 229 | else 230 | { 231 | Assert.True(newerVersionIsAvailable); 232 | Assert.Equal(expected, packageMetadata?.Version.ToString()); 233 | } 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /src/UpdatR/Formatters/TextFormatter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Text; 3 | 4 | namespace UpdatR.Formatters; 5 | 6 | public static class TextFormatter 7 | { 8 | public static string PlainText(Summary summary) 9 | { 10 | var sb = new StringBuilder(); 11 | 12 | sb.AppendLine("------------------------------"); 13 | Title(sb, summary); 14 | sb.AppendLine(); 15 | sb.AppendLine("------------------------------"); 16 | 17 | if (summary.VulnerablePackages.Any()) 18 | { 19 | sb.AppendLine("Vulnerable packages"); 20 | sb.AppendLine("--"); 21 | VulnerablePackages(sb, summary.VulnerablePackages); 22 | sb.AppendLine(); 23 | sb.AppendLine("------------------------------"); 24 | } 25 | 26 | if (summary.DeprecatedPackages.Any()) 27 | { 28 | sb.AppendLine("Deprecated packages"); 29 | sb.AppendLine("--"); 30 | DeprecatedPackages(sb, summary.DeprecatedPackages); 31 | sb.AppendLine(); 32 | sb.AppendLine("------------------------------"); 33 | } 34 | 35 | if (summary.UpdatedPackages.Any()) 36 | { 37 | sb.AppendLine("Updated packages"); 38 | sb.AppendLine("--"); 39 | UpdatedPackages(sb, summary.UpdatedPackages); 40 | sb.AppendLine(); 41 | sb.AppendLine("------------------------------"); 42 | } 43 | 44 | if (summary.UnknownPackages.Count > 0) 45 | { 46 | sb.AppendLine("Not found packages"); 47 | sb.AppendLine("--"); 48 | UnknownPackages(sb, summary.UnknownPackages); 49 | sb.AppendLine(); 50 | sb.AppendLine("------------------------------"); 51 | } 52 | 53 | if (summary.UnauthorizedSources.Any()) 54 | { 55 | sb.AppendLine("Unauthorized sources"); 56 | sb.AppendLine("--"); 57 | UnauthorizedSources(sb, summary.UnauthorizedSources); 58 | sb.AppendLine(); 59 | sb.AppendLine("------------------------------"); 60 | } 61 | 62 | return sb.ToString(); 63 | } 64 | 65 | private static void UnauthorizedSources( 66 | StringBuilder sb, 67 | IEnumerable<(string Name, string Source)> unauthorizedSources 68 | ) 69 | { 70 | foreach (var (name, source) in unauthorizedSources) 71 | { 72 | sb.AppendFormat(new CultureInfo("en-US"), "{0} ({1})", name, source); 73 | sb.AppendLine(); 74 | sb.AppendLine("--"); 75 | } 76 | } 77 | 78 | private static void UnknownPackages( 79 | StringBuilder sb, 80 | IDictionary<string, IEnumerable<string>> unknownPackages 81 | ) 82 | { 83 | foreach (var package in unknownPackages) 84 | { 85 | sb.AppendLine(package.Key); 86 | sb.AppendLine("Used in:"); 87 | foreach (var project in package.Value) 88 | { 89 | sb.Append("- ").AppendLine(project); 90 | } 91 | sb.AppendLine("--"); 92 | } 93 | } 94 | 95 | private static void Title(StringBuilder sb, Summary summary) 96 | { 97 | if (summary.UpdatedPackagesCount == 0) 98 | { 99 | sb.AppendLine("Updated no packages."); 100 | } 101 | else if (summary.UpdatedPackagesCount == 1) 102 | { 103 | sb.Append("📦 Updated ").AppendLine(summary.UpdatedPackages.Single().PackageId); 104 | } 105 | else 106 | { 107 | sb.Append("📦 Updated ").Append(summary.UpdatedPackagesCount).AppendLine(" packages."); 108 | } 109 | } 110 | 111 | private static void DeprecatedPackages( 112 | StringBuilder sb, 113 | IEnumerable<DeprecatedPackage> deprecatedPackages 114 | ) 115 | { 116 | foreach (var (packageId, versions) in deprecatedPackages) 117 | { 118 | sb.AppendLine(packageId); 119 | 120 | var padding = versions 121 | .SelectMany(x => x.Projects.Select(y => y.Length)) 122 | .OrderByDescending(x => x) 123 | .First(); 124 | 125 | foreach (var ((version, metadata), projects) in versions) 126 | { 127 | sb.AppendFormat( 128 | new CultureInfo("en-US"), 129 | "Reason(s): {0}", 130 | string.Join(", ", metadata.Reasons) 131 | ); 132 | 133 | sb.AppendLine(); 134 | 135 | if (metadata.Message is not null) 136 | { 137 | sb.AppendLine(metadata.Message.Replace("\n", Environment.NewLine)); 138 | } 139 | 140 | if (metadata.AlternatePackage is not null) 141 | { 142 | sb.AppendFormat( 143 | new CultureInfo("en-US"), 144 | "Alternate Package: {0}", 145 | metadata.AlternatePackage.PackageId 146 | ) 147 | .AppendLine(); 148 | 149 | sb.AppendFormat( 150 | new CultureInfo("en-US"), 151 | "Version range: {0}", 152 | metadata.AlternatePackage.Range 153 | ) 154 | .AppendLine(); 155 | } 156 | 157 | sb.AppendLine("Package used in:"); 158 | 159 | foreach (var project in projects) 160 | { 161 | sb.AppendFormat( 162 | new CultureInfo("en-US"), 163 | "{0} {1}", 164 | project.PadRight(padding), 165 | version 166 | ); 167 | 168 | sb.AppendLine(); 169 | } 170 | } 171 | sb.AppendLine("--"); 172 | } 173 | } 174 | 175 | private static void VulnerablePackages( 176 | StringBuilder sb, 177 | IEnumerable<VulnerablePackage> vulnerablePackages 178 | ) 179 | { 180 | foreach (var package in vulnerablePackages) 181 | { 182 | sb.AppendLine(package.PackageId); 183 | 184 | foreach (var ((version, vulnerabilities), projects) in package.Versions) 185 | { 186 | foreach (var vulnerability in vulnerabilities) 187 | { 188 | sb.AppendFormat( 189 | new CultureInfo("en-US"), 190 | "Version {0} with severity {1}: {2}", 191 | version, 192 | vulnerability.Severity, 193 | vulnerability.AdvisoryUrl 194 | ); 195 | } 196 | 197 | sb.AppendLine(); 198 | sb.AppendLine("Used in:"); 199 | 200 | foreach (var project in projects) 201 | { 202 | sb.AppendLine(project); 203 | } 204 | } 205 | 206 | sb.AppendLine("--"); 207 | } 208 | } 209 | 210 | private static void UpdatedPackages( 211 | StringBuilder sb, 212 | IEnumerable<UpdatedPackage> updatedPackages 213 | ) 214 | { 215 | foreach (var packages in updatedPackages) 216 | { 217 | if (!packages.Updates.Any()) 218 | { 219 | continue; 220 | } 221 | 222 | var padRightProject = packages 223 | .Updates.Select(x => x.Project.Length) 224 | .OrderByDescending(x => x) 225 | .First(); 226 | 227 | var padRightFrom = packages 228 | .Updates.Select(x => x.From.ToString().Length) 229 | .OrderByDescending(x => x) 230 | .First(); 231 | 232 | sb.AppendLine(packages.PackageId); 233 | 234 | foreach (var (from, to, project) in packages.Updates) 235 | { 236 | sb.AppendFormat( 237 | new CultureInfo("en-US"), 238 | "{0} {1} => {2}", 239 | project.PadRight(padRightProject), 240 | from.ToString().PadRight(padRightFrom), 241 | to 242 | ); 243 | 244 | sb.AppendLine(); 245 | } 246 | sb.AppendLine("--"); 247 | } 248 | } 249 | } 250 | --------------------------------------------------------------------------------