[MSB3482] An error occurred while signing: SignTool.exe was not found at path
I am trying to build .NET Framework assemblies using Rider, without having any version of Visual Studio installed. For the most part I am not having any problems.
However, I am having one build problem.
I want to have MSBuild sign my assembly DLL file ("TargetFileName"), with my certificate value, using the Windows SDK signtool.exe file. However, when I try to do this via a "SignFile" task in my .csproj file, I get a build error stating that the SignTool.exe file was not found at the path where the .csproj file resides. Here is a screen snippet.
**** More Details ****
Note that in my solution, I have selected the JetBrains amd64 version of MSBuild.exe.
Also note that I have also installed just the "Windows SDK Signing Tools for Desktop Apps" feature of the latest Windows SDK. (That is the only Windows SDK feature I currently have installed.) By installing that feature, versions of the Windows SDK signtool.exe file, as well as other files, can now be found installed at the following four locations:
C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm\signtool.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64\signtool.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\signtool.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe
I have the following section of lines (where I have masked my thumbprint value) in my .csproj file that include a "SignFile" task.
<Target Name="Signing" AfterTargets="AfterBuild">
<Message Importance="High" Text="Signing $(TargetFileName) with our certificate..." />
<SignFile CertificateThumbprint="****************************************" SigningTarget="$(OutputPath)$(TargetFileName)" TargetFrameworkVersion="v4.7.2" />
</Target>
Again, as noted earlier, when I build the project, I get the following error:
[project-file-name].csproj(90, 5): [MSB3482] An error occurred while signing: SignTool.exe was not found at path C:\****\[project-folder]\signtool.exe.
I am not sure why MSBuild does not find one of the installed versions of the signtool.exe file. From what I understand, MSBuild should be looking at some other path, or set of paths, before resorting to finally looking for the tool file in the project folder. As MSBuild code is open source, I have downloaded the code from GitHub and tried to follow its logic. It appears that the code is trying in some manner to find the signtool.exe file in "Windows SDK" related paths, but the code is hard to follow.
I can work around the problem with a "hack" where I copy a version of the signtool.exe into the project folder of every project that I want signed using the tool. But this is not an ideal long term solution.
So I am hoping that someone can shed some light on why MSBuild cannot find one of the versions of the signtool.exe tool file installed on my system as part of the Windows SDK. Or knows of additional steps or installations I need to do to get MSBuild to work for me for this build task in Rider.
Note: Last week I was trying to get this to work with Rider version 2022.3.2, and was having the same error. As of today I am using version 2023.1 EAP 4
Note: This works if I additionally install a version of Microsoft Visual Studio on the system. However, the current main point of my experimentation is to specifically get my projects building with Rider, without any version of Visual Studio installed/involved.
Thanks
Please sign in to leave a comment.
Hi Christopher Langenfeld,
MSBuild looks for signtool in a few predetermined locations and I don't believe it tries to look for it in C:\Program Files (x86)\Windows Kits. However it should use the registry to determine the signtool location.
Would you mind creating the following registry key (or update the value if it already exists), pointing it to your SignFile folder and letting me know if the issue persists?
Hi Kirill,
Yes, creating the SignTool registry key and creating a "Path" registry value pointing to my SignTool folder works.
Also, as I am sure you know, another option is to install just the "ClickOnce Publishing" feature of MS Visual Studio. Which installs a copy of the signtool.exe file and creates the appropriate "..\ClickOnce\SignTool" registry data.
However, as I originally stated, my goal is to build .NET Framework assemblies using Rider, without having to install any version and features of Visual Studio. So having to install that one feature (the VS ClickOnce Publishing" feature) defeats the purpose. And having to manually create the registry data, while simple, is still an extra, manual step that would be required by our developers.
Ideally we just want to install Rider and not have to do either of those non-ideal extra steps to be able to use the "SignFile" task in our csproj files. Ideally the Rider version of MSBuild.exe would simply handle finding one of the copies of the signtool.exe file that can be found within the Windows SDK folders.
Hello Christopher,
Apologies for keeping you so long without an answer.
Regrettably, we see no way to make it work for you without workarounds.
Except proper tools (VS, ClickOnce) installation the available options are:
Apologies for the inconvenience.
If there is anything else we can assist you with, please let us know.
Have a nice day!