vcsjones / AzureSignTool

SignTool Library and Azure Key Vault Support
MIT License
272 stars 85 forks source link

Files to sign to support wildcards #206

Closed andyfisher100 closed 4 months ago

andyfisher100 commented 1 year ago

It would be nice if the file to sign could support wildcard signing to sign multiple files from one command such as the following to sign multiple msi files in the same directory C:\BuildOutput\*.msi

This is something that is supported by sign tool itself and would makes life a little easier.

I do realise that the app supports the passing of a file that can contain multiple files to sign, maybe you suggestion is this instead of using wildcards?

malikirfan commented 10 months ago

Yes, it will surely help to support wildcard. As I need to sign all "exe" files in artifact.

johnhydemtm365 commented 8 months ago

Any thoughts on implementing this. We have an electron build that puts the version number into the file name..... so its dynamic...

mcr222 commented 7 months ago

You can use a powershell script to get all files with a wildcard and then use that file as input for the AzureSignTool (option -ifl). You can configure that with a powershell command in an azure yaml. Here is my powershell code as example:

param([string] $toSignFile)

# Get the current folder
$currentFolder = Get-Location

# Specify the subfolder path
$subfolderPath = "subpathtoyourexe\*"
$targetFolderPath = Join-Path $currentFolder $subfolderPath
Write-Output "Finding signature files at $targetFolderPath"

# Find all .exe and .dll files in the specified subfolder
$files = Get-ChildItem -Path $targetFolderPath -Include *.exe,*.dll
Write-Output "All files found $files"

# Specify the output file path
$outputFilePath = Join-Path $currentFolder $toSignFile

# Write the file names to the text file
$files | ForEach-Object {
     $fullName = $_.FullName
    Write-Output $fullName
    $fullName | Out-File -Append -FilePath $outputFilePath
}

Write-Output "File names written to $outputFilePath"

Now you can call if in Azure pipeline using:

 #getting all files to sign in a file
    - task: PowerShell@2
      displayName: Get all files to sign
      inputs:
        arguments: filewithalltosign.txt
        filePath: 'nameoffilewithpreviouscode.ps1'

Now you can use filewithalltosign.txt as input of AzureSingTool -ifl filewithalltosign.txt