diff --git a/src/app/Fake.DotNet.Testing.MSTest/MSTest.fs b/src/app/Fake.DotNet.Testing.MSTest/MSTest.fs index 29f2613fc9b..048bb05a938 100644 --- a/src/app/Fake.DotNet.Testing.MSTest/MSTest.fs +++ b/src/app/Fake.DotNet.Testing.MSTest/MSTest.fs @@ -8,20 +8,14 @@ module MSTest = open System open System.Text + open BlackFox.VsWhere open Fake.Core + open Fake.IO open Fake.Testing.Common - let internal mstestPaths = - [| @"[ProgramFilesX86]\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio\2019\Professional\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio\2019\Community\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio\2017\Professional\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio\2017\Community\Common7\IDE\" - @"[ProgramFilesX86]\Microsoft Visual Studio 14.0\Common7\IDE" - @"[ProgramFilesX86]\Microsoft Visual Studio 12.0\Common7\IDE" - @"[ProgramFilesX86]\Microsoft Visual Studio 11.0\Common7\IDE" - @"[ProgramFilesX86]\Microsoft Visual Studio 10.0\Common7\IDE" |] + let private getAllVsPath () = + VsInstances.getWithPackage "Microsoft.VisualStudio.PackageGroup.TestTools.MSTestV2.Managed" false + |> List.map (fun vs -> Path.combine vs.InstallationPath "Common7\\Tools") let internal msTestExe = if Environment.isWindows then @@ -86,7 +80,7 @@ module MSTest = Tests = [] TimeOut = TimeSpan.FromMinutes 5. ToolPath = - match ProcessUtils.tryFindLocalTool "TOOL" msTestExe mstestPaths with + match ProcessUtils.tryFindLocalTool "TOOL" msTestExe (getAllVsPath ()) with | Some path -> path | None -> "" Details = [] diff --git a/src/app/Fake.DotNet.Testing.MSTest/paket.references b/src/app/Fake.DotNet.Testing.MSTest/paket.references index a8342f4b742..34fc6a37d04 100644 --- a/src/app/Fake.DotNet.Testing.MSTest/paket.references +++ b/src/app/Fake.DotNet.Testing.MSTest/paket.references @@ -2,3 +2,4 @@ group fakemodule FSharp.Core NETStandard.Library +BlackFox.VsWhere diff --git a/src/app/Fake.DotNet.Testing.VSTest/VSTest.fs b/src/app/Fake.DotNet.Testing.VSTest/VSTest.fs index af9209075a0..ecfd8d25ed7 100644 --- a/src/app/Fake.DotNet.Testing.VSTest/VSTest.fs +++ b/src/app/Fake.DotNet.Testing.VSTest/VSTest.fs @@ -2,6 +2,7 @@ open Fake.Core open Fake.Testing.Common +open BlackFox.VsWhere open System open System.IO open System.Text @@ -12,11 +13,11 @@ open System.Text [] module VSTest = - let private vsTestPaths = - [| @"[ProgramFilesX86]\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow" - @"[ProgramFilesX86]\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow" - @"[ProgramFilesX86]\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow" - @"[ProgramFilesX86]\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow" |] + let private guessVSTestPaths () = + let vsTestRelativePath = @"Common7\IDE\CommonExtensions\Microsoft\TestWindow" + + VsInstances.getAll () + |> List.map (fun vs -> Fake.IO.Path.combine vs.InstallationPath vsTestRelativePath) let private vsTestExe = if Environment.isMono then @@ -112,7 +113,7 @@ module VSTest = ListLoggers = false ListSettingsProviders = false ToolPath = - match ProcessUtils.tryFindFile vsTestPaths vsTestExe with + match ProcessUtils.tryFindFile (guessVSTestPaths ()) vsTestExe with | Some path -> path | None -> "" WorkingDir = null diff --git a/src/app/Fake.DotNet.Testing.VSTest/paket.references b/src/app/Fake.DotNet.Testing.VSTest/paket.references index a8342f4b742..34fc6a37d04 100644 --- a/src/app/Fake.DotNet.Testing.VSTest/paket.references +++ b/src/app/Fake.DotNet.Testing.VSTest/paket.references @@ -2,3 +2,4 @@ group fakemodule FSharp.Core NETStandard.Library +BlackFox.VsWhere