16
16
# E.g. VS 2017 Update 1 Preview will have version 15.1.1
17
17
[Parameter (Mandatory = $false )]
18
18
[Alias (" v" )]
19
- [System.String ] $Version = " " , # Will set this later by reading TestPlatform.Settings.targets file.
19
+ [System.String ] $Version , # Will set this later by reading TestPlatform.Settings.targets file.
20
20
21
21
[Parameter (Mandatory = $false )]
22
22
[Alias (" vs" )]
@@ -65,8 +65,12 @@ $env:TP_PACKAGE_PROJ_DIR = Join-Path $env:TP_ROOT_DIR "src\package"
65
65
# Set Version from scripts/build/TestPlatform.Settings.targets
66
66
if ([string ]::IsNullOrWhiteSpace($Version ))
67
67
{
68
- $Version = ([xml ](Get-Content $env: TP_ROOT_DIR \scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup.TPVersionPrefix
69
- $Version = ($Version ).Trim()
68
+ $Version = ([xml ](Get-Content $env: TP_ROOT_DIR \scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup.TPVersionPrefix |
69
+ Where-Object { $_ } |
70
+ ForEach-Object { $_.Trim () } |
71
+ Select-Object - First 1
72
+
73
+ Write-Verbose " Version was not provided using version '$Version ' from TestPlatform.Settings.targets"
70
74
}
71
75
72
76
#
@@ -564,12 +568,12 @@ function Create-VsixPackage
564
568
Update-VsixVersion $vsixProjectDir
565
569
566
570
# Build vsix project to get TestPlatform.vsix
567
- Write-Verbose " $msbuildPath \msbuild.exe $vsixProjectDir \TestPlatform.csproj -p:Configuration=$Configuration "
568
- & $msbuildPath \ msbuild.exe " $vsixProjectDir \TestPlatform.csproj" - p:Configuration= $Configuration
571
+ Write-Verbose " $msbuildPath $vsixProjectDir \TestPlatform.csproj -p:Configuration=$Configuration "
572
+ & $msbuildPath " $vsixProjectDir \TestPlatform.csproj" - p:Configuration= $Configuration
569
573
}
570
574
else
571
- {
572
- Write-Log " .. Create-VsixPackage: Cannot generate vsix as msbuild.exe not found at '$msbuildPath '."
575
+ {
576
+ throw " .. Create-VsixPackage: Cannot generate vsix as msbuild.exe not found at '$msbuildPath '."
573
577
}
574
578
575
579
Write-Log " Create-VsixPackage: Complete. {$ ( Get-ElapsedTime ($timer )) }"
@@ -769,17 +773,16 @@ function PrintAndExit-OnError([System.String] $output)
769
773
function Locate-MSBuildPath
770
774
{
771
775
$vsInstallPath = Locate- VsInstallPath
776
+ $msbuildPath = Get-ChildItem (Join-Path - path $vsInstallPath - childPath " MSBuild\*\Bin\MSBuild.exe" )
772
777
773
- if ([string ]::IsNullOrEmpty($vsInstallPath ))
774
- {
775
- return $null
778
+ Write-Verbose " found msbuild : '$ ( $msbuildPath -join " ','" ) '"
779
+ $msBuild = $msBuildPath | Select-Object - First 1
780
+ Write-Verbose " msbuildPath is : '$ ( $msbuildPath -join " ','" ) '"
781
+ if ($null -eq $msBuild -or 0 -eq $msBuild.Count ) {
782
+ throw " MSBuild not found."
776
783
}
777
784
778
- $vsInstallPath = Resolve-Path - path $vsInstallPath
779
- $msbuildPath = Join-Path - path $vsInstallPath - childPath " MSBuild\$env: MSBUILD_VERSION \Bin"
780
-
781
- Write-Verbose " msbuildPath is : $msbuildPath "
782
- return $msbuildPath
785
+ return $msBuild.FullName
783
786
}
784
787
785
788
function Locate-VsInstallPath
@@ -796,22 +799,31 @@ function Locate-VsInstallPath
796
799
797
800
Try
798
801
{
799
- Write-Verbose " VSWhere command line: $vswhere -version '(15.0,16.0]' -prerelease -products * -requires $requiredPackageIds -property installationPath"
800
802
if ($TPB_CIBuild ) {
801
- $vsInstallPath = & $vswhere - version ' (15.0,16.0]' - products * - requires $requiredPackageIds - property installationPath
803
+ Write-Verbose " VSWhere command line: $vswhere -version '(15.0' -products * -requires $requiredPackageIds -property installationPath"
804
+ $vsInstallPath = & $vswhere - version ' (15.0' - products * - requires $requiredPackageIds - property installationPath
802
805
}
803
806
else {
804
807
# Allow using pre release versions of VS for dev builds
805
- $vsInstallPath = & $vswhere - version ' (15.0,16.0]' - prerelease - products * - requires $requiredPackageIds - property installationPath
808
+ Write-Verbose " VSWhere command line: $vswhere -version '(15.0' -prerelease -products * -requires $requiredPackageIds -property installationPath"
809
+ $vsInstallPath = & $vswhere - version ' (15.0' - prerelease - products * - requires $requiredPackageIds - property installationPath
806
810
}
807
811
}
808
812
Catch [System.Management.Automation.MethodInvocationException ]
809
813
{
810
- Write-Verbose " Failed to find VS installation with requirements : $requiredPackageIds "
814
+ throw " Failed to find VS installation with requirements: $requiredPackageIds "
815
+ }
816
+
817
+ if ($null -eq $vsInstallPath -or 0 -eq @ ($vsInstallPath ).Count) {
818
+ throw " Failed to find VS installation with requirements: $requiredPackageIds "
819
+ }
820
+ else {
821
+ Write-Verbose " Found VS installation with requirements '$ ( $requiredPackageIds -join " ','" ) ' : '$ ( $vsInstallPath -join " ','" ) '."
811
822
}
812
823
813
- Write-Verbose " VSInstallPath is : $vsInstallPath "
814
- return $vsInstallPath
824
+ $vsPath = $vsInstallPath | Select-Object - First 1
825
+ Write-Verbose " VSInstallPath is : $vsPath "
826
+ return $vsPath
815
827
}
816
828
817
829
function Update-VsixVersion ($vsixProjectDir )
0 commit comments