|
93 | 93 | <!-- Under Unix, we don't double %% the format. That only works on Windows. --> |
94 | 94 | <GitCommitDateFormat Condition="'$(GitCommitDateFormat)' == '' and '$(OS)' == 'Windows_NT'">%%cI</GitCommitDateFormat> |
95 | 95 | <GitCommitDateFormat Condition="'$(GitCommitDateFormat)' == '' and '$(OS)' != 'Windows_NT'">%cI</GitCommitDateFormat> |
| 96 | + |
| 97 | + <_VsWherePath>$(ProgramFiles(x86))\Microsoft Visual Studio\Installer\vswhere.exe</_VsWherePath> |
96 | 98 | </PropertyGroup> |
97 | 99 |
|
98 | 100 | <!-- Private properties --> |
|
915 | 917 | <GitExe Condition="'$(GitExe)' == '' and Exists('C:\msysgit\bin\git.exe')">C:\msysgit\bin\git.exe</GitExe> |
916 | 918 | </PropertyGroup> |
917 | 919 |
|
| 920 | + <!-- Fallback to VS-provided Git --> |
| 921 | + <PropertyGroup Condition="'$(GitExe)' == ''"> |
| 922 | + <_VsWherePath>$(MSBuildProgramFiles32)\Microsoft Visual Studio\Installer\vswhere.exe</_VsWherePath> |
| 923 | + <_VsWhere Condition="Exists('$(_VsWherePath)')">$(_VsWherePath)</_VsWhere> |
| 924 | + <_VsGitPath>\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git.exe</_VsGitPath> |
| 925 | + </PropertyGroup> |
| 926 | + |
| 927 | + <!-- This command will return one _VsDir item for each InstallationPath for all installed VS instances --> |
| 928 | + <Exec Command='"$(_VsWhere)" -prerelease -property installationPath' |
| 929 | + Condition="'$(GitExe)' == '' and '$(_VsWhere)' != ''" |
| 930 | + ConsoleToMSBuild="true"> |
| 931 | + <Output TaskParameter="ConsoleOutput" ItemName="_VsDir"/> |
| 932 | + <Output TaskParameter="ExitCode" PropertyName="MSBuildLastExitCode" /> |
| 933 | + </Exec> |
| 934 | + |
| 935 | + <PropertyGroup Condition="'$(GitExe)' == '' and '$(MSBuildLastExitCode)' == '0'"> |
| 936 | + <!-- If we got a successful vswhere exec, and still got no GitExe, attempt to locate at each path --> |
| 937 | + <GitExe Condition="Exists('%(_VsDir.Identity)$(_VsGitPath)')">"%(_VsDir.Identity)$(_VsGitPath)"</GitExe> |
| 938 | + </PropertyGroup> |
| 939 | + |
918 | 940 | <!-- If we didn't find it in the PATH nor the above locations, check for git installed in WSL. --> |
919 | 941 | <Exec Command='"$(MSBuildThisFileDirectory)wslrun.cmd" git --version' |
920 | 942 | EchoOff="true" |
|
0 commit comments