Kjartan
Kjartan

Reputation: 19151

How to specify location of signtool.exe in Azure DevOps?

While trying to sign an application compiled and published from Azure Devops using the Visual Studio Build task, I'm getting the following error message:

An error occurred while signing: SignTool.exe was not found at path 
e:\<my app name>\(...)\signtool.exe. [e:\<my-project>\24\s\(...)\MyProjecName.csproj]

I checked and found that SignTool.exe is found at the following location...

C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool

...but I have no idea how to tell the VS Build task to look for it there.

Is there any way for me to inform the build task about the correct path, or some way to override it? If not, I might consider copying the SignTool into the current directory on each run, but that feels like a dirty hack.

Upvotes: 6

Views: 3009

Answers (2)

Brian Swart
Brian Swart

Reputation: 942

I know you solved your own issue, but I ran into this same issue using the MSBuild task on a self-hosted agent. Posting this in case it helps others or me when I forget that I've already fixed this.

This bug report helped me determine that the issue was caused by using the x64 architecture. Changing the architecture to x86 fixed the issue for me without having to copy the executable to the build folder.

enter image description here

Upvotes: 1

Kjartan
Kjartan

Reputation: 19151

I ended up solving this by checking for the existence of SignTool.exe in the local build path using a Powershell script, and copying it in if not:

# Since MSBuild can't seem to access SignTool.exe from it's existing
# path, make a local copy (if none already exists):
$buildPath = "$(Build.Repository.LocalPath)"
$projPath = "$buildPath\MyProjectNameHere"
$pathToCheck = "$projPath\SignTool.exe"

$signToolPath = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\SignTool.exe"

if(-not (test-path "$pathToCheck")){
    write-host "Copying SignTool to $pathToCheck"
    copy  "$signToolPath" "$projPath"
}

Now at least MSBuild will find the tool and be able to run it.

Upvotes: 3

Related Questions