From df9e7c1c11c02e7db70276ba31d22f668fd76acb Mon Sep 17 00:00:00 2001 From: Alexander Holstrup <117829001+aholstrup1@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:32:10 +0200 Subject: [PATCH] Write output of sign install to log (#1270) * Update the Sign script to log the output of dotnet install to the logs. * Update the sign package to latest. The Sign team recently made an improvement to write a warning if _Visual C++ Runtime_ is not installed. If it isn't, signing will fail because NavSip depends on this assembly. Related to #1252 --- Actions/Packages.json | 2 +- Actions/Sign/Sign.psm1 | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) 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", diff --git a/Actions/Sign/Sign.psm1 b/Actions/Sign/Sign.psm1 index f7207d5d2..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,10 +28,17 @@ 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 + 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" -Resolve + $signingTool = Join-Path -Path $tempFolder "sign.exe" + if (-not (Test-Path -Path $signingTool)) { + # 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 }