Skip to content

Commit

Permalink
Merge pull request #2843 from farlee2121/sf-fix-vstest-paths
Browse files Browse the repository at this point in the history
Discover VSTest and MSTest using VSWhere
  • Loading branch information
xperiandri authored Oct 21, 2024
2 parents 6f2fc43 + ef20bf0 commit b61f117
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
18 changes: 6 additions & 12 deletions src/app/Fake.DotNet.Testing.MSTest/MSTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions src/app/Fake.DotNet.Testing.MSTest/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ group fakemodule

FSharp.Core
NETStandard.Library
BlackFox.VsWhere
13 changes: 7 additions & 6 deletions src/app/Fake.DotNet.Testing.VSTest/VSTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open Fake.Core
open Fake.Testing.Common
open BlackFox.VsWhere
open System
open System.IO
open System.Text
Expand All @@ -12,11 +13,11 @@ open System.Text
[<RequireQualifiedAccess>]
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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/Fake.DotNet.Testing.VSTest/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ group fakemodule

FSharp.Core
NETStandard.Library
BlackFox.VsWhere

0 comments on commit b61f117

Please sign in to comment.