<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->


<Project DefaultTargets="RegisterStrongNameSkip" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Import Project="WixBuild.props" />

  <!--
  ================================================================================================
  RegisterStrongNameSkip

    Trusts the partially signed WiX toolset binaries from a non-official build.
  ================================================================================================
  -->
  <PropertyGroup>
    <NetfxSdkInstallPath>$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0A', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" '$(NetfxSdkInstallPath)'=='' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" '$(NetfxSdkInstallPath)'=='' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" '$(NetfxSdkInstallPath)'=='' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1A', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" '$(NetfxSdkInstallPath)'=='' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" '$(NetfxSdkInstallPath)'=='' ">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A', 'InstallationFolder', null, RegistryView.Registry64, RegistryView.Registry32))</NetfxSdkInstallPath>
    <NetfxSdkInstallPath Condition=" !HasTrailingSlash('$(NetfxSdkInstallPath)') ">$(NetfxSdkInstallPath)\</NetfxSdkInstallPath>
    <StrongNameSignFolder Condition=" Exists('$(NetfxSdkInstallPath)bin\NETFX 4.6.2 Tools\sn.exe') ">$(NetfxSdkInstallPath)bin\NETFX 4.6.2 Tools\</StrongNameSignFolder>
    <StrongNameSignFolder Condition=" Exists('$(NetfxSdkInstallPath)bin\NETFX 4.6.1 Tools\sn.exe') ">$(NetfxSdkInstallPath)bin\NETFX 4.6.1 Tools\</StrongNameSignFolder>
    <StrongNameSignFolder Condition=" Exists('$(NetfxSdkInstallPath)bin\NETFX 4.6 Tools\sn.exe') ">$(NetfxSdkInstallPath)bin\NETFX 4.6 Tools\</StrongNameSignFolder>
    <StrongNameSignFolder Condition=" Exists('$(NetfxSdkInstallPath)bin\NETFX 4.5.1 Tools\sn.exe') ">$(NetfxSdkInstallPath)bin\NETFX 4.5.1 Tools\</StrongNameSignFolder>
    <StrongNameSignFolder Condition=" Exists('$(NetfxSdkInstallPath)bin\NETFX 4.0 Tools\sn.exe') ">$(NetfxSdkInstallPath)bin\NETFX 4.0 Tools\</StrongNameSignFolder>
    <StrongNameSignFolder Condition=" '$(StrongNameSignFolder)'=='' ">$(NetfxSdkInstallPath)bin\</StrongNameSignFolder>
    <StrongNameSign64Folder Condition=" Exists('$(StrongNameSignFolder)x64\sn.exe') ">$(StrongNameSignFolder)x64\</StrongNameSign64Folder>
  </PropertyGroup>
  <Target
    Name="RegisterStrongNameSkip">

    <Error Text="Could not find sn.exe. Expected to find it at: $(StrongNameSignFolder)sn.exe" Condition=" !Exists('$(StrongNameSignFolder)sn.exe') " />

    <Exec Command="&quot;$(StrongNameSign64Folder)sn.exe&quot; -q -Vr *,ce35f76fcda82bad" Condition=" '$(StrongNameSign64Folder)'!='' " />
    <Exec Command="&quot;$(StrongNameSignFolder)sn.exe&quot; -q -Vr *,ce35f76fcda82bad" />
  </Target>

</Project>
