From b9367c0ca662755a7eda7de256717b9c3d77a0f8 Mon Sep 17 00:00:00 2001 From: Davide Giacometti Date: Thu, 24 Nov 2022 20:45:51 +0100 Subject: [PATCH] Fail build when nugets aren't consolidated (#22233) * fail build when nugets aren't consolidated * consolidate nugets * change tool install * consolidate nugets * fix message --- .config/dotnet-tools.json | 12 ++++++++++++ .../ci/templates/build-powertoys-steps.yml | 7 +++++++ .pipelines/verifyNugetPackages.ps1 | 18 ++++++++++++++++++ .../FileLocksmithUI/FileLocksmithUI.csproj | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .config/dotnet-tools.json create mode 100644 .pipelines/verifyNugetPackages.ps1 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000000..f53b78c2705 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-consolidate": { + "version": "2.0.0", + "commands": [ + "dotnet-consolidate" + ] + } + } +} \ No newline at end of file diff --git a/.pipelines/ci/templates/build-powertoys-steps.yml b/.pipelines/ci/templates/build-powertoys-steps.yml index ad4e0a677c6..220b4dc6cf3 100644 --- a/.pipelines/ci/templates/build-powertoys-steps.yml +++ b/.pipelines/ci/templates/build-powertoys-steps.yml @@ -7,6 +7,13 @@ steps: submodules: true clean: true +- task: PowerShell@2 + displayName: Verifying Nuget packages for PowerToys.sln + inputs: + filePath: '$(build.sourcesdirectory)\.pipelines\verifyNugetPackages.ps1' + arguments: -solution '$(build.sourcesdirectory)\PowerToys.sln' + pwsh: true + - task: PowerShell@2 displayName: Verify Arm64 configuration for PowerToys.sln inputs: diff --git a/.pipelines/verifyNugetPackages.ps1 b/.pipelines/verifyNugetPackages.ps1 new file mode 100644 index 00000000000..1fcc5237f0e --- /dev/null +++ b/.pipelines/verifyNugetPackages.ps1 @@ -0,0 +1,18 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True,Position=1)] + [string]$solution +) + +Write-Host "Verifying Nuget packages for $solution" + +dotnet tool restore +dotnet consolidate -s $solution + +if (-not $?) +{ + Write-Host -ForegroundColor Red "Nuget packages with the same name must all be the same version." + exit 1 +} + +exit 0 diff --git a/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj b/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj index f299e68d700..e7e4315e331 100644 --- a/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj +++ b/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj @@ -59,7 +59,7 @@ - +