Changeset 17191


Ignore:
Timestamp:
08/07/19 08:42:01 (3 weeks ago)
Author:
abeham
Message:

#3017: Adapted discovery of msbuild and vstest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Test.ps1

    r17016 r17191  
    11# find ms build
    22$programFilesX86Dir = ($Env:ProgramFiles, ${Env:ProgramFiles(x86)})[[bool]${Env:ProgramFiles(x86)}]
    3 $locations = @(
    4   [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Enterprise")
    5   [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Community")
    6   [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "BuildTools")
    7 )
     3$vsDir = [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio")
     4$years = @("2019", "2017")
     5$editions = @("Enterprise", "Professional", "Community", "BuildTools")
     6$versions = @("Current", "15.0")
    87
     8$msBuildPath = $undefined
    99$vstestPath = $undefined
    10 Foreach ($loc in $locations) {
    11   $vstestloc = [System.IO.Path]::Combine($loc, "Common7", "IDE", "CommonExtensions", "Microsoft", "TestWindow", "vstest.console.exe")
    12   If([System.IO.File]::Exists($vstestloc)) {
    13     $vstestPath = $vstestloc
    14     Break;
     10:search Foreach ($year in $years) {
     11  $loc = [System.IO.Path]::Combine($vsDir, $year)
     12  Foreach ($edition in $editions) {
     13    $edLoc = [System.IO.Path]::Combine($loc, $edition, "MSBuild")
     14    Foreach ($version in $versions) {
     15      $binLoc = [System.IO.Path]::Combine($edLoc, $version, "Bin")
     16      $loc64 = [System.IO.Path]::Combine($binLoc, "amd64", "MSBuild.exe")
     17      $loc32 = [System.IO.Path]::Combine($binLoc, "MSBuild.exe")
     18
     19      If ([System.IO.File]::Exists($loc64)) {
     20        $msBuildPath = $loc64
     21        $vstestPath = [System.IO.Path]::Combine($loc, $edition, "Common7", "IDE", "CommonExtensions", "Microsoft", "TestWindow", "vstest.console.exe")
     22        Break search;
     23      }
     24      If ([System.IO.File]::Exists($loc32)) {
     25        $msBuildPath = $loc32
     26        $vstestPath = [System.IO.Path]::Combine($loc, $edition, "Common7", "IDE", "CommonExtensions", "Microsoft", "TestWindow", "vstest.console.exe")
     27        Break search;
     28      }
     29    }
    1530  }
    1631}
     
    1833If ($vstestPath -eq $undefined) {
    1934  "Could not locate vstest.console.exe, ABORTING ..."
     35  Return
     36}
     37
     38If(-not [System.IO.File]::Exists($vstestPath)) {
     39  "vstest.console.exe is not found at $vstestPath, ABORTING ..."
    2040  Return
    2141}
     
    3959
    4060If($dobuild) {
    41 
    42   $msBuildPath = $undefined
    43   Foreach ($loc in $locations) {
    44     $msbuildloc64 = [System.IO.Path]::Combine($loc, "MSBuild", "15.0", "Bin", "amd64", "MSBuild.exe")
    45     $msbuildloc32 = [System.IO.Path]::Combine($loc, "MSBuild", "15.0", "Bin", "MSBuild.exe")
    46     If ([System.IO.File]::Exists($msbuildloc64)) {
    47       $msBuildPath = $msbuildloc64
    48       Break;
    49     } ElseIf ([System.IO.File]::Exists($msbuildloc32)) {
    50       $msBuildPath = $msbuildloc32
    51       Break;
    52     }
    53   }
    54  
    55   If ($msBuildPath -eq $undefined) {
    56     "Could not locate MSBuild, ABORTING ..."
    57     Return
    58   }
    59 
    6061  $curPath = $MyInvocation.MyCommand.Path
    6162  $curDir = Split-Path $curPath
Note: See TracChangeset for help on using the changeset viewer.