How to tell TeamCity / MS Build where to locate SignTool.exe?

635 views Asked by At

As part of a build-process for a .Net application under TeamCity, we need access to SignTool.exe to sign our program. I have been able to do this by including a copy of SignTool.exe directly into the root folder of the project in question (i.e. including SignTool.exe in the Git repo), but this feels like an ugly solution.

I know SignTool is on the server, and I know it's path too (C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe), yet I haven't been able to find a way to let the build process discover that.

If I try to run the build without the local copy of BuildTool.exe included, then I get the following error:

An error occurred while signing: SignTool.exe was not found at path E:\TC_build_agent_work\(...)

Obviously, this looks for the program directly in the build folder, and fails.

I found some info about adding hints to the project file using the keyword SignToolPath, and experimented a little with it without any success whatsoever.

I also tried to add the correct path as an Environment Variable in TeamCity, but it's not clear to me if or how this should work. In any case, it made no difference to my build.

How can I add the path in such a way that TeamCity (or MS Build?) will pick it up, and look for SignTool.exe in the correct location?

1

There are 1 answers

0
Taratas On

I would extend the Windows environment variable 'Path' to include the path of SignTool.exe. In practice, it is done the same with other tools (docker, nodejs, dotnet, powershell, ...)

set PATH=%PATH%;C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool

Note that you have to restart TeamCity or the agent after making changes to the Path variable.

Alternatively, you could use a TeamCity Build parameter to expand the Path env variable, which then only applies during the build, no restart needed (imo its as ugly as adding the tool to the git repository).

TeamCity BuildConfiguration Parameters