<Project DefaultTargets="RunValidation">
    
    <PropertyGroup>
        <NormalizedToolPath>$([System.IO.Path]::GetDirectoryName($(ToolPath)/))</NormalizedToolPath>
    </PropertyGroup>

    <PropertyGroup>
        <MSBuildExtensionsPathInToolPath>false</MSBuildExtensionsPathInToolPath>
        <MSBuildExtensionsPathInToolPath Condition="$(MSBuildExtensionsPath.StartsWith('$(NormalizedToolPath)'))">true</MSBuildExtensionsPathInToolPath>
        <CscToolExeInToolPath>false</CscToolExeInToolPath>
        <CscToolExeInToolPath Condition="$(CscToolExe.StartsWith('$(NormalizedToolPath)'))">true</CscToolExeInToolPath>
        <MSBuildSDKsPathInToolPath>false</MSBuildSDKsPathInToolPath>
        <MSBuildSDKsPathInToolPath Condition="$(MSBuildSDKsPath.StartsWith('$(NormalizedToolPath)'))">true</MSBuildSDKsPathInToolPath>
    </PropertyGroup>
    
    <Target Name="RunValidation">
        <Error Condition=" '$(ToolPath)' == '' "
            Text="ToolPath not set" />

        <Error Condition=" '$(MSBuildExtensionsPathInToolPath)' == 'false' "
               Text="MSBuildExtensionsPath '$(MSBuildExtensionsPath)' not in ToolPath '$(NormalizedToolPath)'" />

        <Error Condition=" '$(CscToolExeInToolPath)' == 'false' "
               Text="CscToolExe '$(CscToolExe)' not in ToolPath '$(NormalizedToolPath)'" />

        <Error Condition=" '$(MSBuildSDKsPathInToolPath)' == 'false' "
               Text="MSBuildSDKsPath '$(MSBuildSDKsPath)' not in ToolPath '$(NormalizedToolPath)'" />
    </Target>
</Project>