Reputation: 5236
I am trying to get my WiX bootstrap installer signed in Visual Studio. I am following example shown in WiX: Digitally Sign BootStrapper project
Unfortunately had to use explicit path to sign tool to get it to work...
<Target Name="UsesFrameworkSdk">
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="FrameworkSdkPath" />
</GetFrameworkSdkPath>
<Message Text="SDK path = '$(FrameworkSdkPath)'" Importance="high"/>
</Target>
<Target Name="UsesSignTool" DependsOnTargets="UsesFrameworkSdk">
<PropertyGroup>
<SignToolPath>C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe</SignToolPath>
</PropertyGroup>
</Target>
The FrameworkSdkPath variable returns "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\" which is not where the sign tool is.
If I start a VS command tool the environment variable WindowsSdkDir is set to the the directory containing signtool.exe. However this variable is not set within Visual Studio.
How to do this properly so I don't have to set explicit path?
Upvotes: 1
Views: 675
Reputation: 5236
The accepted answer is no longer valid for most recent versions of the SDK because the bin folder has moved. Here is the correction:
<Target Name="UsesFrameworkSdk">
<PropertyGroup>
<Win10SDKBinPath>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)bin\</Win10SDKBinPath>
<Win10SDKVersion>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion).0\</Win10SDKVersion>
<Win10SDKVerBinPath>$(Win10SDKBinPath)$(Win10SDKVersion)
</Win10SDKVerBinPath>
</PropertyGroup>
</Target>
<Target Name="UsesSignTool" DependsOnTargets="UsesFrameworkSdk">
<PropertyGroup>
<SignToolPath Condition="('@(SignToolPath)'=='') and Exists('$(Win10SDKVerBinPath)x86\signtool.exe')">$(Win10SDKVerBinPath)x86\signtool.exe</SignToolPath>
</PropertyGroup>
</Target>
Upvotes: 1
Reputation: 1660
How to do this properly so I don't have to set explicit path?
From the example, we could get the path from registry. like this:
<Target Name="UsesFrameworkSdk">
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="FrameworkSdkPath" />
</GetFrameworkSdkPath>
<PropertyGroup>
<Win10SDK>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)</Win10SDK>
</PropertyGroup>
<Message Text="SDK path = '$(Win10SDK)'" Importance="high"/>
</Target>
<Target Name="UsesSignTool" DependsOnTargets="UsesFrameworkSdk">
<PropertyGroup>
<SignToolPath Condition="('@(SignToolPath)'=='') and Exists('$(Win10SDK)\bin\x86\signtool.exe')">$(Win10SDK)\bin\x86\signtool.exe</SignToolPath>
</PropertyGroup>
</Target>
Upvotes: 1