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.
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.