@@ -18,19 +18,23 @@ namespace Cake.Common.Tools.VSWhere
1818 public abstract class VSWhereTool < TSettings > : Tool < TSettings >
1919 where TSettings : ToolSettings
2020 {
21+ private const string VSWhereExecutableName = "vswhere.exe" ;
22+ private readonly ICakeEnvironment _environment ;
23+
2124 /// <summary>
2225 /// Initializes a new instance of the <see cref="VSWhereTool{TSettings}"/> class.
2326 /// </summary>
2427 /// <param name="fileSystem">The file system.</param>
2528 /// <param name="environment">The environment.</param>
2629 /// <param name="processRunner">The process runner.</param>
27- /// <param name="toolLocator">The tool servce .</param>
30+ /// <param name="toolLocator">The tool locator service .</param>
2831 protected VSWhereTool ( IFileSystem fileSystem ,
2932 ICakeEnvironment environment ,
3033 IProcessRunner processRunner ,
3134 IToolLocator toolLocator )
3235 : base ( fileSystem , environment , processRunner , toolLocator )
3336 {
37+ _environment = environment ;
3438 }
3539
3640 /// <summary>
@@ -48,7 +52,27 @@ protected override string GetToolName()
4852 /// <returns>The tool executable name.</returns>
4953 protected override IEnumerable < string > GetToolExecutableNames ( )
5054 {
51- return new [ ] { "vswhere.exe" } ;
55+ return new [ ] { VSWhereExecutableName } ;
56+ }
57+
58+ /// <summary>
59+ /// Gets alternative file paths which the tool may exist in
60+ /// </summary>
61+ /// <param name="settings">The settings.</param>
62+ /// <returns>The default tool path.</returns>
63+ protected override IEnumerable < FilePath > GetAlternativeToolPaths ( TSettings settings )
64+ {
65+ /*
66+ * According to https://blogs.msdn.microsoft.com/heaths/2017/04/21/vswhere-is-now-installed-with-visual-studio-2017/,
67+ * Starting in the latest preview release of Visual Studio version 15.2 (26418.1-Preview), you can now find vswhere installed in
68+ * “%ProgramFiles(x86)%\Microsoft Visual Studio\Installer” (on 32-bit operating systems before Windows 10, you should use
69+ * “%ProgramFiles%\Microsoft Visual Studio\Installer”).
70+ */
71+
72+ return new FilePath [ ]
73+ {
74+ _environment . GetSpecialPath ( _environment . Platform . Is64Bit ? SpecialPath . ProgramFilesX86 : SpecialPath . ProgramFiles ) . CombineWithFilePath ( "Microsoft Visual Studio/Installer/" + VSWhereExecutableName ) ,
75+ } ;
5276 }
5377
5478 /// <summary>
0 commit comments