Path to SignTool.exe or “Windows Kits” directory when using Visual Studio 2012

前端 未结 7 1791
-上瘾入骨i
-上瘾入骨i 2021-01-30 09:04

How do you get the path to SignTool.exe when using Visual Studio 2012?

In Visual Studio 2010, you could use



        
7条回答
  •  生来不讨喜
    2021-01-30 09:30

    The following is a more generic approach that can be used to find and set the SignToolPath variable based upon the build machine's specific configuration; by reading the registry:

    
        $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot81', null, RegistryView.Registry32, RegistryView.Default))
        $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default))
        $(WindowsKitsRoot)bin\$(Platform)\
    
    

    This assumes that $(Platform) resolves to one of arm, x86, or x64. Replace the $(Platform) macro with the appropriate directory otherwise.

    EDIT (2017.07.05):
    Here is an updated that defers to the new Windows 10 Kit and coerces the ($Platform)=='AnyCPU' to x86:

    
      $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot10', null, RegistryView.Registry32, RegistryView.Default))
      $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot81', null, RegistryView.Registry32, RegistryView.Default))
      $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default))
      $(WindowsKitsRoot)bin\x86\
      $(WindowsKitsRoot)bin\$(Platform)\
    
    

提交回复
热议问题