Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover VSTest and MSTest using VSWhere #2843

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading