From bb698573857a588e19c3961b0403fc38e921ef1b Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 22 Oct 2024 09:23:19 +0200 Subject: [PATCH 1/3] Get more meaningful information into log --- Actions/Sign/Sign.psm1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Actions/Sign/Sign.psm1 b/Actions/Sign/Sign.psm1 index f7207d5d2..a52ef0c0d 100644 --- a/Actions/Sign/Sign.psm1 +++ b/Actions/Sign/Sign.psm1 @@ -16,10 +16,14 @@ function Install-SigningTool() { # Install the signing tool in the temp folder Write-Host "Installing signing tool version $version in $tempFolder" New-Item -ItemType Directory -Path $tempFolder | Out-Null - dotnet tool install sign --version $version --tool-path $tempFolder | Out-Null + $dotnetInstallOutput = dotnet tool install sign --version $version --tool-path $tempFolder + Write-Host $dotnetInstallOutput # Return the path to the signing tool - $signingTool = Join-Path -Path $tempFolder "sign.exe" -Resolve + $signingTool = Join-Path -Path $tempFolder "sign.exe" + if (-not (Test-Path -Path $signingTool)) { + throw "Failed to install signing tool. If you are using a self-hosted runner, make sure the runner has .NET installed and nuget.org set up as a nuget source." + } return $signingTool } From 9aad73be97c5380d4f34f14313601553a686ba0d Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 22 Oct 2024 09:26:15 +0200 Subject: [PATCH 2/3] Update sign package --- Actions/Packages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Actions/Packages.json b/Actions/Packages.json index 3eeff0daf..879db6674 100644 --- a/Actions/Packages.json +++ b/Actions/Packages.json @@ -1,5 +1,5 @@ { - "sign": "0.9.1-beta.24123.2", + "sign": "0.9.1-beta.24469.1", "Microsoft.ApplicationInsights": "2.20.0", "Az.Accounts": "2.15.1", "Az.Storage": "6.1.1", From dcd94bc9db6e2da8db57b64dfe82e2de9532c359 Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Wed, 23 Oct 2024 10:03:33 +0200 Subject: [PATCH 3/3] Feedback --- Actions/Sign/Sign.psm1 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Actions/Sign/Sign.psm1 b/Actions/Sign/Sign.psm1 index a52ef0c0d..3d8d9fce9 100644 --- a/Actions/Sign/Sign.psm1 +++ b/Actions/Sign/Sign.psm1 @@ -1,3 +1,15 @@ +<# + .SYNOPSIS + Checks whether nuget.org is added as a nuget source. +#> +function AssertNugetSourceIsAdded() { + $nugetSource = "https://api.nuget.org/v3/index.json" + $nugetSourceExists = dotnet nuget list source | Select-String -Pattern $nugetSource + if (-not $nugetSourceExists) { + throw "Nuget source $nugetSource is not added. Please add the source using 'dotnet nuget add source $nugetSource' or add another source with nuget.org as an upstream source." + } +} + <# .SYNOPSIS Installs the dotnet signing tool. @@ -16,13 +28,16 @@ function Install-SigningTool() { # Install the signing tool in the temp folder Write-Host "Installing signing tool version $version in $tempFolder" New-Item -ItemType Directory -Path $tempFolder | Out-Null - $dotnetInstallOutput = dotnet tool install sign --version $version --tool-path $tempFolder - Write-Host $dotnetInstallOutput + dotnet tool install sign --version $version --tool-path $tempFolder | Out-Host # Return the path to the signing tool $signingTool = Join-Path -Path $tempFolder "sign.exe" if (-not (Test-Path -Path $signingTool)) { - throw "Failed to install signing tool. If you are using a self-hosted runner, make sure the runner has .NET installed and nuget.org set up as a nuget source." + # Check if nuget.org is added as a nuget source + AssertNugetSourceIsAdded + + # If the tool is not found, throw an error + throw "Failed to install signing tool. If you are using a self-hosted runner please make sure you've followed all the steps described in https://aka.ms/algosettings#runs-on." } return $signingTool }