<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion = "4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 
    <PropertyGroup>
        <!-- If no files are found in the <Choose> block, we'll default to the latest, even if it results in an MSBuild error -->
        <VCToolsVersionPlatformPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v145.default.props))</VCToolsVersionPlatformPath>
    </PropertyGroup>

    <!-- MSVC Platform Toolset will be searched from newest to oldest (v145,v143,v142,v141) -->
    <!-- In this mode, there is a possibility of the project's PlatformToolset setting and the chosen props file being out of sync -->
    <Choose>
        <When Condition="EXISTS('$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v145.default.props))')">
            <PropertyGroup>
                <VCToolsVersionPlatformPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v145.default.props))</VCToolsVersionPlatformPath>
            </PropertyGroup>
        </When>
        <When Condition="EXISTS('$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v143.default.props))')">
            <PropertyGroup>
                <VCToolsVersionPlatformPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v143.default.props))</VCToolsVersionPlatformPath>
            </PropertyGroup>
        </When>
        <When Condition="EXISTS('$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v142.default.props))')">
            <PropertyGroup>
                <VCToolsVersionPlatformPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v142.default.props))</VCToolsVersionPlatformPath>
            </PropertyGroup>
        </When>
        <When Condition="EXISTS('$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v141.default.props))')">
            <PropertyGroup>
                <VCToolsVersionPlatformPath>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\Microsoft.VCToolsVersion.v141.default.props))</VCToolsVersionPlatformPath>
            </PropertyGroup>
        </When>
    </Choose>
    
    <!-- Import the determined props file -->
    <Import Project="$(VCToolsVersionPlatformPath)" />

    <PropertyGroup>
        <!-- Clean-up VCToolsVersionPlatformPath -->
        <VCToolsVersionPlatformPath></VCToolsVersionPlatformPath>
    </PropertyGroup>
</Project>